Skip to content

Commit

Permalink
Merge branch 'release-1.11' into s3profilefix-1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
reasonerjt authored Aug 7, 2023
2 parents 408bafa + d901977 commit aca6279
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/6593-Lyndon-Li
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions changelogs/unreleased/6597-Lyndon-Li
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions pkg/controller/restore_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/repository/provider/unified_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const (
repoOpDescMaintain = "repo maintenance"
repoOpDescForget = "forget"

repoConnectDesc = "unfied repo"
repoConnectDesc = "unified repo"
)

// NewUnifiedRepoProvider creates the service provider for Unified Repo
Expand Down Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions pkg/repository/provider/unified_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ func TestForget(t *testing.T) {
backupRepo *reposervicenmocks.BackupRepo
retFuncOpen []interface{}
retFuncDelete interface{}
retFuncFlush interface{}
credStoreReturn string
credStoreError error
expectedErr string
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit aca6279

Please sign in to comment.