Skip to content

Commit

Permalink
Merge pull request #393 from Xieql/update-backup-api
Browse files Browse the repository at this point in the history
backup: update migrate api
  • Loading branch information
kurator-bot committed Oct 12, 2023
2 parents ac55a90 + bbc6e01 commit 1a2db3a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 24 deletions.
17 changes: 12 additions & 5 deletions docs/content/en/references/backups_v1alpha1_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ <h3 id="backup.kurator.dev/v1alpha1.Migrate">Migrate
</em>
</td>
<td>
<p>TargetCluster represents the target clusters for migration.</p>
<p>TargetClusters represents the target clusters for migration.</p>
</td>
</tr>
<tr>
Expand All @@ -563,7 +563,6 @@ <h3 id="backup.kurator.dev/v1alpha1.Migrate">Migrate
</em>
</td>
<td>
<em>(Optional)</em>
<p>Policy defines the rules for the migration.</p>
</td>
</tr>
Expand All @@ -586,6 +585,13 @@ <h3 id="backup.kurator.dev/v1alpha1.Migrate">Migrate
</table>
</div>
</div>
<h3 id="backup.kurator.dev/v1alpha1.MigratePhase">MigratePhase
(<code>string</code> alias)</h3>
<p>
(<em>Appears on:</em>
<a href="#backup.kurator.dev/v1alpha1.MigrateStatus">MigrateStatus</a>)
</p>
<p>MigratePhase is a string representation of the lifecycle phase of a Migrate instance</p>
<h3 id="backup.kurator.dev/v1alpha1.MigratePolicy">MigratePolicy
</h3>
<p>
Expand Down Expand Up @@ -722,7 +728,7 @@ <h3 id="backup.kurator.dev/v1alpha1.MigrateSpec">MigrateSpec
</em>
</td>
<td>
<p>TargetCluster represents the target clusters for migration.</p>
<p>TargetClusters represents the target clusters for migration.</p>
</td>
</tr>
<tr>
Expand All @@ -735,7 +741,6 @@ <h3 id="backup.kurator.dev/v1alpha1.MigrateSpec">MigrateSpec
</em>
</td>
<td>
<em>(Optional)</em>
<p>Policy defines the rules for the migration.</p>
</td>
</tr>
Expand Down Expand Up @@ -777,7 +782,9 @@ <h3 id="backup.kurator.dev/v1alpha1.MigrateStatus">MigrateStatus
<td>
<code>phase</code><br>
<em>
string
<a href="#backup.kurator.dev/v1alpha1.MigratePhase">
MigratePhase
</a>
</em>
</td>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
51 changes: 45 additions & 6 deletions pkg/apis/backups/v1alpha1/migrate_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down Expand Up @@ -90,20 +89,52 @@ 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
Conditions capiv1.Conditions `json:"conditions,omitempty"`

// 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.
Expand All @@ -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
}
16 changes: 4 additions & 12 deletions pkg/apis/backups/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1a2db3a

Please sign in to comment.