diff --git a/pkg/controller/restore_controller.go b/pkg/controller/restore_controller.go index 804d2b467..02a971715 100644 --- a/pkg/controller/restore_controller.go +++ b/pkg/controller/restore_controller.go @@ -297,6 +297,8 @@ func (controller *restoreController) getValidationErrors(itm *api.Restore) []str if itm.Spec.BackupName == "" { validationErrors = append(validationErrors, "BackupName must be non-empty and correspond to the name of a backup in object storage.") + } else if _, err := controller.fetchBackup(controller.bucket, itm.Spec.BackupName); err != nil { + validationErrors = append(validationErrors, fmt.Sprintf("Error retrieving backup: %v", err)) } includedResources := sets.NewString(itm.Spec.IncludedResources...) diff --git a/pkg/controller/restore_controller_test.go b/pkg/controller/restore_controller_test.go index 0462a55ac..c75ab28f0 100644 --- a/pkg/controller/restore_controller_test.go +++ b/pkg/controller/restore_controller_test.go @@ -183,8 +183,8 @@ func TestProcessRestore(t *testing.T) { name: "restore with non-existent backup name fails", restore: arktest.NewTestRestore("foo", "bar", api.RestorePhaseNew).WithBackup("backup-1").WithIncludedNamespace("ns-1").Restore, expectedErr: false, - expectedPhase: string(api.RestorePhaseInProgress), - expectedRestoreErrors: 1, + expectedPhase: string(api.RestorePhaseFailedValidation), + expectedValidationErrors: []string{"Error retrieving backup: no backup here"}, backupServiceGetBackupError: errors.New("no backup here"), }, {