diff --git a/pkg/clustercache/controller.go b/pkg/clustercache/controller.go index f879323d6..972808676 100644 --- a/pkg/clustercache/controller.go +++ b/pkg/clustercache/controller.go @@ -216,6 +216,7 @@ func (h *clusterCache) List(gvr schema2.GroupVersionResource) []interface{} { } func (h *clusterCache) start() { + defer h.workqueue.ShutDown() for { eventObj, ok := h.workqueue.Get() if ok { @@ -235,18 +236,22 @@ func (h *clusterCache) start() { _, err := callAll(h.changeHandlers.List(), event.gvr, key, event.obj, event.oldObj) if err != nil { logrus.Errorf("failed to handle add event: %v", err) + h.workqueue.AddAfter(eventObj, 5*time.Second) } } else if event.add { _, err := callAll(h.addHandlers.List(), event.gvr, key, event.obj, nil) if err != nil { logrus.Errorf("failed to handle add event: %v", err) + h.workqueue.AddAfter(eventObj, 5*time.Second) } } else { _, err := callAll(h.removeHandlers.List(), event.gvr, key, event.obj, nil) if err != nil { logrus.Errorf("failed to handle remove event: %v", err) + h.workqueue.AddAfter(eventObj, 5*time.Second) } } + h.workqueue.Done(eventObj) } }