diff --git a/pkg/controller/gc_controller.go b/pkg/controller/gc_controller.go index 05c512130..8f3e7165e 100644 --- a/pkg/controller/gc_controller.go +++ b/pkg/controller/gc_controller.go @@ -99,7 +99,10 @@ func NewGCController( backupInformer.Informer().AddEventHandler( cache.ResourceEventHandlerFuncs{ - UpdateFunc: c.handleFinalizer, + AddFunc: c.handleFinalizer, + UpdateFunc: func(_, upd interface{}) { + c.handleFinalizer(upd) + }, }, ) @@ -108,9 +111,9 @@ func NewGCController( // handleFinalizer runs garbage-collection on a backup that has the Ark GC // finalizer and a deletionTimestamp. -func (c *gcController) handleFinalizer(_, newObj interface{}) { +func (c *gcController) handleFinalizer(obj interface{}) { var ( - backup = newObj.(*api.Backup) + backup = obj.(*api.Backup) log = c.logger.WithField("backup", kube.NamespaceAndName(backup)) ) diff --git a/pkg/controller/gc_controller_test.go b/pkg/controller/gc_controller_test.go index 69415d44e..dd26a0ea5 100644 --- a/pkg/controller/gc_controller_test.go +++ b/pkg/controller/gc_controller_test.go @@ -348,7 +348,7 @@ func TestHandleFinalizer(t *testing.T) { } // METHOD UNDER TEST - controller.handleFinalizer(nil, test.backup) + controller.handleFinalizer(test.backup) // VERIFY backupService.AssertExpectations(t)