Merge pull request #271 from nrb/fix-246

Invalidate restores based on non-existent backups
pull/285/head
Andy Goldstein 2018-01-10 13:24:53 -05:00 committed by GitHub
commit f5f1dbac5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -297,6 +297,8 @@ func (controller *restoreController) getValidationErrors(itm *api.Restore) []str
if itm.Spec.BackupName == "" { if itm.Spec.BackupName == "" {
validationErrors = append(validationErrors, "BackupName must be non-empty and correspond to the name of a backup in object storage.") 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...) includedResources := sets.NewString(itm.Spec.IncludedResources...)

View File

@ -183,8 +183,8 @@ func TestProcessRestore(t *testing.T) {
name: "restore with non-existent backup name fails", name: "restore with non-existent backup name fails",
restore: arktest.NewTestRestore("foo", "bar", api.RestorePhaseNew).WithBackup("backup-1").WithIncludedNamespace("ns-1").Restore, restore: arktest.NewTestRestore("foo", "bar", api.RestorePhaseNew).WithBackup("backup-1").WithIncludedNamespace("ns-1").Restore,
expectedErr: false, expectedErr: false,
expectedPhase: string(api.RestorePhaseInProgress), expectedPhase: string(api.RestorePhaseFailedValidation),
expectedRestoreErrors: 1, expectedValidationErrors: []string{"Error retrieving backup: no backup here"},
backupServiceGetBackupError: errors.New("no backup here"), backupServiceGetBackupError: errors.New("no backup here"),
}, },
{ {