From 7eac6675e86b0b9d73eac3c8af4a061a090eba77 Mon Sep 17 00:00:00 2001 From: Nolan Brubaker Date: Thu, 17 May 2018 11:37:08 -0400 Subject: [PATCH] Exit when failing to update a backup's phase Signed-off-by: Nolan Brubaker --- pkg/controller/backup_deletion_controller.go | 1 + .../backup_deletion_controller_test.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/pkg/controller/backup_deletion_controller.go b/pkg/controller/backup_deletion_controller.go index 06ba01bc9..0ef449c34 100644 --- a/pkg/controller/backup_deletion_controller.go +++ b/pkg/controller/backup_deletion_controller.go @@ -211,6 +211,7 @@ func (c *backupDeletionController) processRequest(req *v1.DeleteBackupRequest) e }) if err != nil { log.WithError(errors.WithStack(err)).Error("Error setting backup phase to deleting") + return err } var errs []string diff --git a/pkg/controller/backup_deletion_controller_test.go b/pkg/controller/backup_deletion_controller_test.go index c28fc8704..e607f5bd0 100644 --- a/pkg/controller/backup_deletion_controller_test.go +++ b/pkg/controller/backup_deletion_controller_test.go @@ -263,6 +263,22 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) { assert.EqualError(t, err, "error patching DeleteBackupRequest: bad") }) + t.Run("patching backup to Deleting fails", func(t *testing.T) { + backup := arktest.NewTestBackup().WithName("foo").WithSnapshot("pv-1", "snap-1").Backup + td := setupBackupDeletionControllerTest(backup) + defer td.backupService.AssertExpectations(t) + + td.client.PrependReactor("patch", "deletebackuprequests", func(action core.Action) (bool, runtime.Object, error) { + return true, td.req, nil + }) + td.client.PrependReactor("patch", "backups", func(action core.Action) (bool, runtime.Object, error) { + return true, nil, errors.New("bad") + }) + + err := td.controller.processRequest(td.req) + assert.EqualError(t, err, "error patching Backup: bad") + }) + t.Run("unable to find backup", func(t *testing.T) { td := setupBackupDeletionControllerTest() defer td.backupService.AssertExpectations(t)