Skip to content

Commit 76fdab3

Browse files
authored
chore: support to restore from encryption backup (#9428)
1 parent 4d2d722 commit 76fdab3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

controllers/dataprotection/backup_controller.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,9 @@ func (r *BackupReconciler) handleRunningPhase(
573573
if err != nil {
574574
return r.updateStatusIfFailed(reqCtx, backup.DeepCopy(), backup, err)
575575
}
576+
if err = r.syncContinuousBackupEncryptionConfig(reqCtx, backup, request.BackupPolicy); err != nil {
577+
return intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, "sync continuous backup encryption config failed")
578+
}
576579
var (
577580
existFailedAction bool
578581
waiting bool
@@ -657,6 +660,17 @@ func (r *BackupReconciler) handleRunningPhase(
657660
return intctrlutil.Reconciled()
658661
}
659662

663+
func (r *BackupReconciler) syncContinuousBackupEncryptionConfig(reqCtx intctrlutil.RequestCtx, backup *dpv1alpha1.Backup, backupPolicy *dpv1alpha1.BackupPolicy) error {
664+
if backup.Labels[dptypes.BackupTypeLabelKey] != string(dpv1alpha1.BackupTypeContinuous) {
665+
return nil
666+
}
667+
if !reflect.DeepEqual(backup.Status.EncryptionConfig, backupPolicy.Spec.EncryptionConfig) {
668+
backup.Status.EncryptionConfig = backupPolicy.Spec.EncryptionConfig
669+
return r.Client.Status().Update(reqCtx.Ctx, backup)
670+
}
671+
return nil
672+
}
673+
660674
// checkIsCompletedDuringRunning when continuous schedule is disabled or cluster has been deleted,
661675
// backup phase should be Completed.
662676
func (r *BackupReconciler) checkIsCompletedDuringRunning(reqCtx intctrlutil.RequestCtx,

0 commit comments

Comments
 (0)