diff --git a/docs/content/en/references/backups_v1alpha1_types.html b/docs/content/en/references/backups_v1alpha1_types.html index 79165f90f..038b6bf6c 100644 --- a/docs/content/en/references/backups_v1alpha1_types.html +++ b/docs/content/en/references/backups_v1alpha1_types.html @@ -550,7 +550,7 @@

Migrate -

TargetCluster represents the target clusters for migration.

+

TargetClusters represents the target clusters for migration.

@@ -563,7 +563,6 @@

Migrate -(Optional)

Policy defines the rules for the migration.

@@ -586,6 +585,13 @@

Migrate +

MigratePhase +(string alias)

+

+(Appears on: +MigrateStatus) +

+

MigratePhase is a string representation of the lifecycle phase of a Migrate instance

MigratePolicy

@@ -722,7 +728,7 @@

MigrateSpec -

TargetCluster represents the target clusters for migration.

+

TargetClusters represents the target clusters for migration.

@@ -735,7 +741,6 @@

MigrateSpec -(Optional)

Policy defines the rules for the migration.

@@ -777,7 +782,9 @@

MigrateStatus phase
-string + +MigratePhase + diff --git a/manifests/charts/fleet-manager/crds/backup.kurator.dev_migrates.yaml b/manifests/charts/fleet-manager/crds/backup.kurator.dev_migrates.yaml index 80f46837b..d70e924ef 100644 --- a/manifests/charts/fleet-manager/crds/backup.kurator.dev_migrates.yaml +++ b/manifests/charts/fleet-manager/crds/backup.kurator.dev_migrates.yaml @@ -390,7 +390,7 @@ spec: - fleet type: object targetCluster: - description: TargetCluster represents the target clusters for migration. + description: TargetClusters represents the target clusters for migration. properties: clusters: description: Clusters allows users to specify a subset of clusters @@ -522,6 +522,13 @@ spec: type: array phase: description: Phase represents the current phase of the migration operation. + enum: + - New + - FailedValidation + - WaitingForSource + - InProgress + - Completed + - Failed type: string sourceClusterStatus: description: SourceClusterStatus provides a detailed status for backup diff --git a/pkg/apis/backups/v1alpha1/migrate_type.go b/pkg/apis/backups/v1alpha1/migrate_type.go index 91c3df127..ebcf580fe 100644 --- a/pkg/apis/backups/v1alpha1/migrate_type.go +++ b/pkg/apis/backups/v1alpha1/migrate_type.go @@ -40,14 +40,13 @@ type MigrateSpec struct { // The user needs to ensure that SourceCluster points to only ONE cluster. // Because the current migration only supports migrating from one SourceCluster to one or more TargetCluster. // +required - SourceCluster *Destination `json:"sourceCluster"` + SourceCluster Destination `json:"sourceCluster"` - // TargetCluster represents the target clusters for migration. + // TargetClusters represents the target clusters for migration. // +required - TargetCluster *Destination `json:"targetCluster"` + TargetClusters Destination `json:"targetCluster"` // Policy defines the rules for the migration. - // +optional Policy *MigratePolicy `json:"policy,omitempty"` } @@ -90,6 +89,38 @@ type MigratePolicy struct { PreserveNodePorts *bool `json:"preserveNodePorts,omitempty"` } +// MigratePhase is a string representation of the lifecycle phase of a Migrate instance +// +kubebuilder:validation:Enum=New;FailedValidation;WaitingForSource;InProgress;Completed;Failed +type MigratePhase string + +const ( + // MigratePhasePending means the migrate has been created but not + // yet processed by the RestoreController + MigratePhasePending MigratePhase = "Pending" + + // MigratePhaseFailedValidation means the migrate has failed + // the controller's validations and therefore will not run. + MigratePhaseFailedValidation MigratePhase = "FailedValidation" + + // MigratePhaseWaitingForSource means the migrate is currently fetching source cluster resource. + MigratePhaseWaitingForSource MigratePhase = "WaitingForSource" + + // MigratePhaseInProgress means the migrate is currently executing migrating. + MigratePhaseInProgress MigratePhase = "InProgress" + + // MigratePhaseCompleted means the migrate has run successfully + // without errors. + MigratePhaseCompleted MigratePhase = "Completed" + + // MigratePhaseFailed means the migrate was unable to execute. + MigratePhaseFailed MigratePhase = "Failed" +) + +const ( + // SourceReadyCondition reports on whether the resource of backup in source cluster is ready. + SourceReadyCondition capiv1.ConditionType = "sourceReady" +) + type MigrateStatus struct { // Conditions represent the current state of the migration operation. // +optional @@ -97,13 +128,13 @@ type MigrateStatus struct { // Phase represents the current phase of the migration operation. // +optional - Phase string `json:"phase,omitempty"` + Phase MigratePhase `json:"phase,omitempty"` // SourceClusterStatus provides a detailed status for backup in SourceCluster. SourceClusterStatus *BackupDetails `json:"sourceClusterStatus,omitempty"` // TargetClusterStatus provides a detailed status for each restore in each TargetCluster. - TargetClusterStatus []*RestoreDetails `json:"targetClusterStatus,omitempty"` + TargetClustersStatus []*RestoreDetails `json:"targetClusterStatus,omitempty"` } // MigrateList contains a list of Migrate. @@ -114,3 +145,11 @@ type MigrateList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []Migrate `json:"items"` } + +func (m *Migrate) GetConditions() capiv1.Conditions { + return m.Status.Conditions +} + +func (m *Migrate) SetConditions(conditions capiv1.Conditions) { + m.Status.Conditions = conditions +} diff --git a/pkg/apis/backups/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/backups/v1alpha1/zz_generated.deepcopy.go index 78e1028cb..3828253a1 100644 --- a/pkg/apis/backups/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/backups/v1alpha1/zz_generated.deepcopy.go @@ -355,16 +355,8 @@ func (in *MigratePolicy) DeepCopy() *MigratePolicy { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MigrateSpec) DeepCopyInto(out *MigrateSpec) { *out = *in - if in.SourceCluster != nil { - in, out := &in.SourceCluster, &out.SourceCluster - *out = new(Destination) - (*in).DeepCopyInto(*out) - } - if in.TargetCluster != nil { - in, out := &in.TargetCluster, &out.TargetCluster - *out = new(Destination) - (*in).DeepCopyInto(*out) - } + in.SourceCluster.DeepCopyInto(&out.SourceCluster) + in.TargetClusters.DeepCopyInto(&out.TargetClusters) if in.Policy != nil { in, out := &in.Policy, &out.Policy *out = new(MigratePolicy) @@ -398,8 +390,8 @@ func (in *MigrateStatus) DeepCopyInto(out *MigrateStatus) { *out = new(BackupDetails) (*in).DeepCopyInto(*out) } - if in.TargetClusterStatus != nil { - in, out := &in.TargetClusterStatus, &out.TargetClusterStatus + if in.TargetClustersStatus != nil { + in, out := &in.TargetClustersStatus, &out.TargetClustersStatus *out = make([]*RestoreDetails, len(*in)) for i := range *in { if (*in)[i] != nil {