add an AddFunc to handle finalizers in GC for initial lists/resyncs

Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
Steve Kriss
2018-02-28 16:56:23 -08:00
parent 52641e8e29
commit 509431909a
2 changed files with 7 additions and 4 deletions

View File

@@ -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))
)

View File

@@ -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)