diff --git a/changelogs/unreleased/6593-Lyndon-Li b/changelogs/unreleased/6593-Lyndon-Li new file mode 100644 index 0000000000..d72a27778c --- /dev/null +++ b/changelogs/unreleased/6593-Lyndon-Li @@ -0,0 +1 @@ +Fix issue 6575, flush the repo after delete the snapshot, otherwise, the changes(deleting repo snapshot) cannot be committed to the repo. \ No newline at end of file diff --git a/changelogs/unreleased/6597-Lyndon-Li b/changelogs/unreleased/6597-Lyndon-Li new file mode 100644 index 0000000000..67232c0833 --- /dev/null +++ b/changelogs/unreleased/6597-Lyndon-Li @@ -0,0 +1 @@ +Fix issue #6571, fix the problem for restore item operation to set the errors correctly so that they can be recorded by Velero restore and then reflect the correct status for Velero restore. \ No newline at end of file diff --git a/pkg/controller/restore_controller.go b/pkg/controller/restore_controller.go index c2da5b77d5..ce528c2d63 100644 --- a/pkg/controller/restore_controller.go +++ b/pkg/controller/restore_controller.go @@ -477,8 +477,8 @@ func (r *restoreReconciler) runValidatedRestore(restore *api.Restore, info backu // Completed yet. inProgressOperations, _, opsCompleted, opsFailed, errs := getRestoreItemOperationProgress(restoreReq.Restore, pluginManager, *restoreReq.GetItemOperationsList()) if len(errs) > 0 { - for err := range errs { - restoreLog.Error(err) + for _, err := range errs { + restoreErrors.Velero = append(restoreErrors.Velero, fmt.Sprintf("error from restore item operation: %v", err)) } } diff --git a/pkg/repository/provider/unified_repo.go b/pkg/repository/provider/unified_repo.go index 9161e06210..129f2ae6b0 100644 --- a/pkg/repository/provider/unified_repo.go +++ b/pkg/repository/provider/unified_repo.go @@ -66,7 +66,7 @@ const ( repoOpDescMaintain = "repo maintenance" repoOpDescForget = "forget" - repoConnectDesc = "unfied repo" + repoConnectDesc = "unified repo" ) // NewUnifiedRepoProvider creates the service provider for Unified Repo @@ -301,6 +301,11 @@ func (urp *unifiedRepoProvider) Forget(ctx context.Context, snapshotID string, p return errors.Wrap(err, "error to delete manifest") } + err = bkRepo.Flush(ctx) + if err != nil { + return errors.Wrap(err, "error to flush repo") + } + log.Debug("Forget snapshot complete") return nil diff --git a/pkg/repository/provider/unified_repo_test.go b/pkg/repository/provider/unified_repo_test.go index e33059c2b7..ee8ce4f429 100644 --- a/pkg/repository/provider/unified_repo_test.go +++ b/pkg/repository/provider/unified_repo_test.go @@ -734,6 +734,7 @@ func TestForget(t *testing.T) { backupRepo *reposervicenmocks.BackupRepo retFuncOpen []interface{} retFuncDelete interface{} + retFuncFlush interface{} credStoreReturn string credStoreError error expectedErr string @@ -794,6 +795,37 @@ func TestForget(t *testing.T) { }, expectedErr: "error to delete manifest: fake-error-3", }, + { + name: "flush fail", + getter: new(credmock.SecretStore), + credStoreReturn: "fake-password", + funcTable: localFuncTable{ + getStorageVariables: func(*velerov1api.BackupStorageLocation, string, string) (map[string]string, error) { + return map[string]string{}, nil + }, + getStorageCredentials: func(*velerov1api.BackupStorageLocation, velerocredentials.FileStore) (map[string]string, error) { + return map[string]string{}, nil + }, + }, + repoService: new(reposervicenmocks.BackupRepoService), + backupRepo: new(reposervicenmocks.BackupRepo), + retFuncOpen: []interface{}{ + func(context.Context, udmrepo.RepoOptions) udmrepo.BackupRepo { + return backupRepo + }, + + func(context.Context, udmrepo.RepoOptions) error { + return nil + }, + }, + retFuncDelete: func(context.Context, udmrepo.ID) error { + return nil + }, + retFuncFlush: func(context.Context) error { + return errors.New("fake-error-4") + }, + expectedErr: "error to flush repo: fake-error-4", + }, } for _, tc := range testCases { @@ -822,6 +854,7 @@ func TestForget(t *testing.T) { if tc.backupRepo != nil { backupRepo.On("DeleteManifest", mock.Anything, mock.Anything).Return(tc.retFuncDelete) + backupRepo.On("Flush", mock.Anything).Return(tc.retFuncFlush) backupRepo.On("Close", mock.Anything).Return(nil) }