Skip to content

Commit e541b6e

Browse files
committed
Implemented progress tracking for storage migrations
- Added progress tracking for storage migrations - Added completed out of total virtual machines column to migration plan status - Modified migplan conditions to better indicate the actual state of the plan - Updated the kubernetes client to 1.34 Signed-off-by: Alexander Wels <awels@redhat.com>
1 parent dc89ce3 commit e541b6e

File tree

1,339 files changed

+124069
-38435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,339 files changed

+124069
-38435
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
109109
# Remove the datavolumetemplatespecs CRD because it is not needed
110110
rm config/crd/bases/kubevirt.io_datavolumetemplatespecs.yaml
111111
$(CONTROLLER_GEN) crd paths="./vendor/kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1/..." output:crd:artifacts:config=config/crd/bases
112+
$(CONTROLLER_GEN) crd paths="./vendor/github.com/openshift/api/route/v1" output:crd:artifacts:config=config/crd/bases
112113

113114
.PHONY: generate
114115
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.

api/migrationcontroller/v1alpha1/conditions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
const (
1515
ReconcileFailed = "ReconcileFailed"
1616
Ready = "Ready"
17+
Progressing = "Progressing"
1718
Running = "Running"
1819
Failed = "Failed"
1920
Succeeded = "Succeeded"

api/migrationcontroller/v1alpha1/virtualmachinestoragemigration_types.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,15 @@ type Phase string
5353
// VirtualMachineStorageMigrationStatus defines the observed state of VirtualMachineStorageMigration
5454
type VirtualMachineStorageMigrationStatus struct {
5555
Conditions `json:",inline"`
56-
Phase Phase `json:"phase,omitempty"`
57-
Errors []string `json:"errors,omitempty"`
58-
RunningMigrations []string `json:"runningMigrations,omitempty"`
59-
CompletedMigrations []string `json:"completedMigrations,omitempty"`
56+
Phase Phase `json:"phase,omitempty"`
57+
Errors []string `json:"errors,omitempty"`
58+
RunningMigrations []RunningVirtualMachineMigration `json:"runningMigrations,omitempty"`
59+
CompletedMigrations []string `json:"completedMigrations,omitempty"`
60+
}
61+
62+
type RunningVirtualMachineMigration struct {
63+
Name string `json:"name"`
64+
Progress string `json:"progress,omitempty"`
6065
}
6166

6267
// +kubebuilder:object:root=true
@@ -65,8 +70,7 @@ type VirtualMachineStorageMigrationStatus struct {
6570
// VirtualMachineStorageMigration is the Schema for the virtualmachinestoragemigrations API
6671
// +k8s:openapi-gen=true
6772
// +genclient
68-
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=".status.conditions[?(@.type=='Ready')].status"
69-
// +kubebuilder:printcolumn:name="Plan",type=string,JSONPath=".spec.migPlanRef.name"
73+
// +kubebuilder:printcolumn:name="Plan",type=string,JSONPath=".spec.virtualMachineStorageMigrationPlanRef.name"
7074
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=".status.phase"
7175
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
7276
type VirtualMachineStorageMigration struct {
@@ -132,18 +136,19 @@ func HasFinalizer(object metav1.Object, value string) bool {
132136
// SetFinalizer adds the passed in finalizer to the migration
133137
func (r *VirtualMachineStorageMigration) AddFinalizer(finalizer string, log logr.Logger) {
134138
if HasFinalizer(r, finalizer) {
135-
log.Info("Finalizer already exists", "finalizer", finalizer)
139+
log.V(5).Info("Finalizer already exists", "finalizer", finalizer)
136140
return
137141
}
138142
r.Finalizers = append(r.Finalizers, finalizer)
139-
log.Info("Added finalizer", "finalizer", finalizer)
143+
log.V(5).Info("Added finalizer", "finalizer", finalizer)
140144
}
141145

142146
// RemoveFinalizer removes the passed in finalizer from the migration
143-
func (r *VirtualMachineStorageMigration) RemoveFinalizer(finalizer string) {
147+
func (r *VirtualMachineStorageMigration) RemoveFinalizer(finalizer string, log logr.Logger) {
144148
for i, f := range r.Finalizers {
145149
if f == finalizer {
146150
r.Finalizers = append(r.Finalizers[:i], r.Finalizers[i+1:]...)
151+
log.V(5).Info("Removed finalizer", "finalizer", finalizer)
147152
break
148153
}
149154
}

api/migrationcontroller/v1alpha1/virtualmachinestoragemigrationplan_types.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ type VirtualMachineStorageMigrationPlanDestinationPVC struct {
8181

8282
// MigPlanStatus defines the observed state of MigPlan
8383
type VirtualMachineStorageMigrationPlanStatus struct {
84+
// The number of virtual machines that have been completed out of the total number of virtual machines.
85+
CompletedOutOf string `json:"completedOutOf,omitempty"`
8486
// Ready migrations are migrations that are ready to be started.
8587
ReadyMigrations []VirtualMachineStorageMigrationPlanStatusVirtualMachine `json:"readyMigrations,omitempty"`
8688
// Invalid migrations are migrations that are invalid and cannot be started.
@@ -111,7 +113,9 @@ func (r *VirtualMachineStorageMigrationPlan) GetSuffix() string {
111113
// VirtualMachineStorageMigrationPlan is the Schema for the virtualmachinestoragemigrationplans API
112114
// +genclient
113115
// +k8s:openapi-gen=true
114-
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=".status.phase"
116+
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=".status.conditions[?(@.type=='Ready')].status"
117+
// +kubebuilder:printcolumn:name="Progressing",type=string,JSONPath=".status.conditions[?(@.type=='Progressing')].status"
118+
// +kubebuilder:printcolumn:name="Completed VMs",type=string,JSONPath=".status.completedOutOf"
115119
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
116120
type VirtualMachineStorageMigrationPlan struct {
117121
metav1.TypeMeta `json:",inline"`

api/migrationcontroller/v1alpha1/zz_generated.deepcopy.go

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"k8s.io/apimachinery/pkg/runtime"
3030
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3131
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
32+
"k8s.io/client-go/rest"
3233
ctrl "sigs.k8s.io/controller-runtime"
3334
"sigs.k8s.io/controller-runtime/pkg/certwatcher"
3435
"sigs.k8s.io/controller-runtime/pkg/healthz"
@@ -37,6 +38,7 @@ import (
3738
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3839
"sigs.k8s.io/controller-runtime/pkg/webhook"
3940

41+
routev1 "github.com/openshift/api/route/v1"
4042
virtv1 "kubevirt.io/api/core/v1"
4143
cdiv1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
4244

@@ -55,7 +57,7 @@ func init() {
5557
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
5658
utilruntime.Must(virtv1.AddToScheme(scheme))
5759
utilruntime.Must(cdiv1.AddToScheme(scheme))
58-
60+
utilruntime.Must(routev1.AddToScheme(scheme))
5961
utilruntime.Must(migrations.AddToScheme(scheme))
6062
// +kubebuilder:scaffold:scheme
6163
}
@@ -184,7 +186,10 @@ func main() {
184186
})
185187
}
186188

187-
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
189+
cfg := ctrl.GetConfigOrDie()
190+
cfg.WarningHandler = rest.NoWarnings{}
191+
192+
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
188193
Scheme: scheme,
189194
Metrics: metricsServerOptions,
190195
WebhookServer: webhookServer,
@@ -212,6 +217,7 @@ func main() {
212217
Client: mgr.GetClient(),
213218
Scheme: mgr.GetScheme(),
214219
EventRecorder: mgr.GetEventRecorderFor("storagemigplan-controller"),
220+
Log: ctrl.Log.WithName("storagemigplan-controller"),
215221
}).SetupWithManager(mgr); err != nil {
216222
setupLog.Error(err, "unable to create controller", "controller", "StorageMigrationPlan")
217223
os.Exit(1)
@@ -220,6 +226,7 @@ func main() {
220226
Client: mgr.GetClient(),
221227
Scheme: mgr.GetScheme(),
222228
EventRecorder: mgr.GetEventRecorderFor("storagemig-controller"),
229+
Log: ctrl.Log.WithName("storagemig-controller"),
223230
}).SetupWithManager(mgr); err != nil {
224231
setupLog.Error(err, "unable to create controller", "controller", "StorageMigration")
225232
os.Exit(1)

config/crd/bases/cdi.kubevirt.io_cdiconfigs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ spec:
141141
Claims lists the names of resources, defined in spec.resourceClaims,
142142
that are used by this container.
143143
144-
This is an alpha field and requires enabling the
144+
This field depends on the
145145
DynamicResourceAllocation feature gate.
146146
147147
This field is immutable. It can only be set for containers.
@@ -371,7 +371,7 @@ spec:
371371
Claims lists the names of resources, defined in spec.resourceClaims,
372372
that are used by this container.
373373
374-
This is an alpha field and requires enabling the
374+
This field depends on the
375375
DynamicResourceAllocation feature gate.
376376
377377
This field is immutable. It can only be set for containers.

0 commit comments

Comments
 (0)