Skip to content

Commit

Permalink
Skip syncing the backup which doesn't contain backup metadata
Browse files Browse the repository at this point in the history
Skip syncing the backup which doesn't contain backup metadata

Fixes vmware-tanzu#6849

Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
  • Loading branch information
ywk253100 committed Nov 10, 2023
1 parent cb5ffe2 commit 84c9604
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/7081-ywk253100
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Skip syncing the backup which doesn't contain backup metadata
10 changes: 10 additions & 0 deletions pkg/controller/backup_sync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/backup_sync_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 84c9604

Please sign in to comment.