Skip to content

Commit a9358aa

Browse files
zijiren233apecloud-bot
authored andcommitted
fix(dataprotection): prevent infinite job creation loop during backup foreground deletion (#9958)
(cherry picked from commit 53e5262)
1 parent dc8b5b4 commit a9358aa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

controllers/dataprotection/backup_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ func (r *BackupReconciler) parseBackupJob(_ context.Context, object client.Objec
203203

204204
// deleteBackupFiles deletes the backup files stored in backup repository.
205205
func (r *BackupReconciler) deleteBackupFiles(reqCtx intctrlutil.RequestCtx, backup *dpv1alpha1.Backup) error {
206+
// If the dataprotection finalizer has already been removed, the deletion has succeeded.
207+
// Skip creating a new deletion job to avoid a race condition with the garbage collector
208+
// during foreground cascading deletion, which would cause an infinite loop of job creation.
209+
if !controllerutil.ContainsFinalizer(backup, dptypes.DataProtectionFinalizerName) {
210+
return nil
211+
}
212+
206213
deleteBackup := func() error {
207214
// remove backup finalizers to delete it
208215
patch := client.MergeFrom(backup.DeepCopy())

0 commit comments

Comments
 (0)