Merge pull request #343 from skriss/gc-bug

add an AddFunc to handle finalizers in GC for initial lists/resyncs
pull/360/head
Andy Goldstein 2018-03-06 16:41:57 -05:00 committed by GitHub
commit 7328fd0e10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -99,7 +99,10 @@ func NewGCController(
backupInformer.Informer().AddEventHandler( backupInformer.Informer().AddEventHandler(
cache.ResourceEventHandlerFuncs{ 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 // handleFinalizer runs garbage-collection on a backup that has the Ark GC
// finalizer and a deletionTimestamp. // finalizer and a deletionTimestamp.
func (c *gcController) handleFinalizer(_, newObj interface{}) { func (c *gcController) handleFinalizer(obj interface{}) {
var ( var (
backup = newObj.(*api.Backup) backup = obj.(*api.Backup)
log = c.logger.WithField("backup", kube.NamespaceAndName(backup)) log = c.logger.WithField("backup", kube.NamespaceAndName(backup))
) )

View File

@ -348,7 +348,7 @@ func TestHandleFinalizer(t *testing.T) {
} }
// METHOD UNDER TEST // METHOD UNDER TEST
controller.handleFinalizer(nil, test.backup) controller.handleFinalizer(test.backup)
// VERIFY // VERIFY
backupService.AssertExpectations(t) backupService.AssertExpectations(t)