Skip to content

Commit

Permalink
Drop things from the queue when completed
Browse files Browse the repository at this point in the history
  • Loading branch information
dramich committed Apr 16, 2020
1 parent 4645d8d commit 0de13ab
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/clustercache/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
}

Expand Down

0 comments on commit 0de13ab

Please sign in to comment.