Skip to content

Commit 056a3cf

Browse files
BREAKING CHANGE: rename MantleBackup's ReadyToUse to SnapshotCaptured
This commit renames MantleBackup's ReadyToUse condition to SnapshotCaptured. This is a breaking change; before deploying it, users should stop all of the mantle-controller Pods in the primary and secondary clusters, patch the conditions by hand, and then start the new controller. Signed-off-by: Ryotaro Banno <ryotaro.banno@gmail.com>
1 parent 0ec02c4 commit 056a3cf

16 files changed

Lines changed: 106 additions & 106 deletions

api/v1/mantlebackup_types.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ type MantleBackupStatus struct {
5757
}
5858

5959
const (
60-
BackupConditionReadyToUse = "ReadyToUse"
61-
BackupConditionSyncedToRemote = "SyncedToRemote"
62-
BackupConditionVerified = "Verified"
60+
BackupConditionSnapshotCaptured = "SnapshotCaptured"
61+
BackupConditionSyncedToRemote = "SyncedToRemote"
62+
BackupConditionVerified = "Verified"
6363

64-
// Reasons for ConditionReadyToUse
65-
ConditionReasonReadyToUseNoProblem = "NoProblem"
64+
// Reasons for ConditionSnapshotCaptured
65+
ConditionReasonSnapshotCapturedNoProblem = "NoProblem"
6666
// Reasons for ConditionSyncedToRemote
6767
ConditionReasonSyncedToRemoteNoProblem = "NoProblem"
6868
// Reasons for ConditionVerified
@@ -93,8 +93,8 @@ type MantleBackupList struct {
9393
Items []MantleBackup `json:"items"`
9494
}
9595

96-
func (m *MantleBackup) IsReady() bool {
97-
return meta.IsStatusConditionTrue(m.Status.Conditions, BackupConditionReadyToUse)
96+
func (m *MantleBackup) IsSnapshotCaptured() bool {
97+
return meta.IsStatusConditionTrue(m.Status.Conditions, BackupConditionSnapshotCaptured)
9898
}
9999

100100
func (m *MantleBackup) IsSynced() bool {

docs/design.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ spec:
134134
expire: 2w # when the MantleBackup should expire.
135135
status:
136136
conditions:
137-
# The corresponding backup data is ready to use if `status` is "True"
138-
- type: "ReadyToUse"
137+
# The corresponding backup data has been captured if `status` is "True".
138+
- type: "SnapshotCaptured"
139139
status: "True"
140140
```
141141

internal/controller/mantlebackup_controller.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ func (r *MantleBackupReconciler) reconcileLocalBackup(ctx context.Context, backu
429429
return ctrl.Result{}, err
430430
}
431431

432-
if !backup.IsReady() {
432+
if !backup.IsSnapshotCaptured() {
433433
if err := r.provisionRBDSnapshot(ctx, backup, target); err != nil {
434434
return ctrl.Result{}, err
435435
}
@@ -519,14 +519,14 @@ func (r *MantleBackupReconciler) reconcileAsSecondary(ctx context.Context, backu
519519
return ctrl.Result{}, err
520520
}
521521

522-
if !backup.IsReady() {
522+
if !backup.IsSnapshotCaptured() {
523523
result, err := r.startImport(ctx, backup, target)
524524
if err != nil || !result.IsZero() {
525525
return result, err
526526
}
527527
}
528528

529-
if backup.IsReady() && !backup.IsVerifiedTrue() && !backup.IsVerifiedFalse() {
529+
if backup.IsSnapshotCaptured() && !backup.IsVerifiedTrue() && !backup.IsVerifiedFalse() {
530530
if err := r.verify(ctx, backup); err != nil {
531531
return ctrl.Result{}, err
532532
}
@@ -590,7 +590,7 @@ func (r *MantleBackupReconciler) replicate(
590590
return ctrl.Result{}, err
591591
}
592592

593-
if prepareResult.isSecondaryMantleBackupReadyToUse {
593+
if prepareResult.isSecondaryMantleBackupSnapshotCaptured {
594594
if err := r.updateMantleBackupCondition(
595595
ctx, backup,
596596
mantlev1.BackupConditionSyncedToRemote,
@@ -888,7 +888,7 @@ func (r *MantleBackupReconciler) provisionRBDSnapshot(
888888
}
889889

890890
meta.SetStatusCondition(&backup.Status.Conditions, metav1.Condition{
891-
Type: mantlev1.BackupConditionReadyToUse, Status: metav1.ConditionTrue, Reason: mantlev1.ConditionReasonReadyToUseNoProblem})
891+
Type: mantlev1.BackupConditionSnapshotCaptured, Status: metav1.ConditionTrue, Reason: mantlev1.ConditionReasonSnapshotCapturedNoProblem})
892892

893893
return nil
894894
}); err != nil {
@@ -987,9 +987,9 @@ func (r *MantleBackupReconciler) finalizeSecondary(
987987
}
988988

989989
type dataSyncPrepareResult struct {
990-
isIncremental bool // NOTE: The value is forcibly set to false if isSecondaryMantleBackupReadyToUse is true.
991-
isSecondaryMantleBackupReadyToUse bool
992-
diffFrom *mantlev1.MantleBackup // non-nil value iff isIncremental is true.
990+
isIncremental bool // NOTE: The value is forcibly set to false if isSecondaryMantleBackupSnapshotCaptured is true.
991+
isSecondaryMantleBackupSnapshotCaptured bool
992+
diffFrom *mantlev1.MantleBackup // non-nil value iff isIncremental is true.
993993
}
994994

995995
func (r *MantleBackupReconciler) prepareForDataSynchronization(
@@ -1023,23 +1023,23 @@ func (r *MantleBackupReconciler) prepareForDataSynchronization(
10231023
return nil, fmt.Errorf("secondary MantleBackup not found: %s, %s",
10241024
backup.GetName(), backup.GetNamespace())
10251025
}
1026-
isSecondaryMantleBackupReadyToUse := secondaryBackup.IsReady()
1026+
isSecondaryMantleBackupSnapshotCaptured := secondaryBackup.IsSnapshotCaptured()
10271027

1028-
if isSecondaryMantleBackupReadyToUse {
1028+
if isSecondaryMantleBackupSnapshotCaptured {
10291029
return &dataSyncPrepareResult{
1030-
isIncremental: false,
1031-
isSecondaryMantleBackupReadyToUse: true,
1032-
diffFrom: nil,
1030+
isIncremental: false,
1031+
isSecondaryMantleBackupSnapshotCaptured: true,
1032+
diffFrom: nil,
10331033
}, nil
10341034
}
10351035

10361036
if syncMode, ok := backup.GetAnnotations()[annotSyncMode]; ok {
10371037
switch syncMode {
10381038
case syncModeFull:
10391039
return &dataSyncPrepareResult{
1040-
isIncremental: false,
1041-
isSecondaryMantleBackupReadyToUse: isSecondaryMantleBackupReadyToUse,
1042-
diffFrom: nil,
1040+
isIncremental: false,
1041+
isSecondaryMantleBackupSnapshotCaptured: isSecondaryMantleBackupSnapshotCaptured,
1042+
diffFrom: nil,
10431043
}, nil
10441044
case syncModeIncremental:
10451045
diffFromName, ok := backup.GetAnnotations()[annotDiffFrom]
@@ -1057,9 +1057,9 @@ func (r *MantleBackupReconciler) prepareForDataSynchronization(
10571057
}
10581058

10591059
return &dataSyncPrepareResult{
1060-
isIncremental: true,
1061-
isSecondaryMantleBackupReadyToUse: isSecondaryMantleBackupReadyToUse,
1062-
diffFrom: &diffFrom,
1060+
isIncremental: true,
1061+
isSecondaryMantleBackupSnapshotCaptured: isSecondaryMantleBackupSnapshotCaptured,
1062+
diffFrom: &diffFrom,
10631063
}, nil
10641064
default:
10651065
return nil, fmt.Errorf("unknown sync mode: %s", syncMode)
@@ -1080,9 +1080,9 @@ func (r *MantleBackupReconciler) prepareForDataSynchronization(
10801080
isIncremental := (diffFrom != nil)
10811081

10821082
return &dataSyncPrepareResult{
1083-
isIncremental: isIncremental,
1084-
isSecondaryMantleBackupReadyToUse: isSecondaryMantleBackupReadyToUse,
1085-
diffFrom: diffFrom,
1083+
isIncremental: isIncremental,
1084+
isSecondaryMantleBackupSnapshotCaptured: isSecondaryMantleBackupSnapshotCaptured,
1085+
diffFrom: diffFrom,
10861086
}, nil
10871087
}
10881088

@@ -1106,7 +1106,7 @@ func searchForDiffOriginMantleBackup(
11061106
if !ok {
11071107
continue
11081108
}
1109-
if !primaryBackup.IsReady() || !secondaryBackup.IsReady() {
1109+
if !primaryBackup.IsSnapshotCaptured() || !secondaryBackup.IsSnapshotCaptured() {
11101110
continue
11111111
}
11121112
if !primaryBackup.DeletionTimestamp.IsZero() || !secondaryBackup.DeletionTimestamp.IsZero() {
@@ -2030,8 +2030,8 @@ func (r *MantleBackupReconciler) startImport(
20302030
return ctrl.Result{}, fmt.Errorf("failed to unlock the volume: %w", err)
20312031
}
20322032

2033-
if err := r.markSecondaryReadyToUse(ctx, backup, target); err != nil {
2034-
return ctrl.Result{}, fmt.Errorf("failed to mark the secondary as ready to use: %w", err)
2033+
if err := r.markSecondarySnapshotCaptured(ctx, backup, target); err != nil {
2034+
return ctrl.Result{}, fmt.Errorf("failed to mark the secondary as snapshot captured: %w", err)
20352035
}
20362036

20372037
return ctrl.Result{}, nil
@@ -2821,8 +2821,8 @@ func (r *MantleBackupReconciler) createOrUpdateImportJob(
28212821
return err
28222822
}
28232823

2824-
// markSecondaryReadyToUse marks the MantleBackup ReadyToUse as True.
2825-
func (r *MantleBackupReconciler) markSecondaryReadyToUse(
2824+
// markSecondarySnapshotCaptured marks the MantleBackup SnapshotCaptured as True.
2825+
func (r *MantleBackupReconciler) markSecondarySnapshotCaptured(
28262826
ctx context.Context,
28272827
backup *mantlev1.MantleBackup,
28282828
snapshotTarget *snapshotTarget,
@@ -2838,13 +2838,13 @@ func (r *MantleBackupReconciler) markSecondaryReadyToUse(
28382838
return fmt.Errorf("failed to find imported RBD snapshot: %w", err)
28392839
}
28402840

2841-
// Update the status of the MantleBackup to set True to the ReadyToUse condition.
2841+
// Update the status of the MantleBackup to set True to the SnapshotCaptured condition.
28422842
if err := updateStatus(ctx, r.Client, backup, func() error {
28432843
backup.Status.SnapID = &snapshot.Id
28442844
meta.SetStatusCondition(&backup.Status.Conditions, metav1.Condition{
2845-
Type: mantlev1.BackupConditionReadyToUse,
2845+
Type: mantlev1.BackupConditionSnapshotCaptured,
28462846
Status: metav1.ConditionTrue,
2847-
Reason: mantlev1.ConditionReasonReadyToUseNoProblem,
2847+
Reason: mantlev1.ConditionReasonSnapshotCapturedNoProblem,
28482848
})
28492849

28502850
return nil

0 commit comments

Comments
 (0)