diff --git a/changelogs/unreleased/7080-ywk253100 b/changelogs/unreleased/7080-ywk253100 new file mode 100644 index 00000000000..bc142a31643 --- /dev/null +++ b/changelogs/unreleased/7080-ywk253100 @@ -0,0 +1 @@ +Skip syncing the backup which doesn't contain backup metadata \ No newline at end of file diff --git a/pkg/controller/backup_sync_controller.go b/pkg/controller/backup_sync_controller.go index 2fb61d6032b..74122fef307 100644 --- a/pkg/controller/backup_sync_controller.go +++ b/pkg/controller/backup_sync_controller.go @@ -142,6 +142,16 @@ func (b *backupSyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) log = log.WithField("backup", backupName) log.Info("Attempting to sync backup into cluster") + exist, err := backupStore.BackupExists(location.Spec.ObjectStorage.Bucket, backupName) + if err != nil { + log.WithError(errors.WithStack(err)).Error("Error checking backup exist from backup store") + continue + } + if !exist { + log.Debugf("backup %s doesn't exist in backup store, skip", backupName) + continue + } + backup, err := backupStore.GetBackupMetadata(backupName) if err != nil { log.WithError(errors.WithStack(err)).Error("Error getting backup metadata from backup store") diff --git a/pkg/controller/backup_sync_controller_test.go b/pkg/controller/backup_sync_controller_test.go index 86ca3227b1f..885cdd6856e 100644 --- a/pkg/controller/backup_sync_controller_test.go +++ b/pkg/controller/backup_sync_controller_test.go @@ -429,6 +429,7 @@ var _ = Describe("Backup Sync Reconciler", func() { backupNames = append(backupNames, backup.backup.Name) backupStore.On("GetBackupMetadata", backup.backup.Name).Return(backup.backup, nil) backupStore.On("GetPodVolumeBackups", backup.backup.Name).Return(backup.podVolumeBackups, nil) + backupStore.On("BackupExists", "bucket-1", backup.backup.Name).Return(true, nil) } backupStore.On("ListBackups").Return(backupNames, nil) }