Skip to content

Commit 0fbf9c4

Browse files
smanpathakAMecea
authored andcommitted
Remove work items from queues on cluster deletion
1 parent ede0217 commit 0fbf9c4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pkg/controller/clustercontroller/controller.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ func (c *Controller) workerController(stopCh <-chan struct{}) {
195195

196196
// process items from queue
197197
cluster, err := c.getNextWorkItem(key)
198+
if err != nil && k8errors.IsNotFound(err) {
199+
// If the cluster has disappeared, do not re-queue
200+
glog.Infof("Removing issuer %q from processing queue", key)
201+
c.queue.Forget(obj)
202+
return nil
203+
}
204+
198205
if err != nil {
199206
return fmt.Errorf("failed to get cluster: %s", err)
200207
}
@@ -248,6 +255,11 @@ func (c *Controller) workerRecouncile(stopCh <-chan struct{}) {
248255
// process items from queue
249256
cluster, err := c.getNextWorkItem(key)
250257
if err != nil {
258+
if k8errors.IsNotFound(err) {
259+
// key was removed from map, don't reconcile.
260+
glog.Infof("Removing issuer %q from reconcile queue", key)
261+
return nil
262+
}
251263
return fmt.Errorf("failed to get cluster: %s", err)
252264
}
253265

@@ -283,7 +295,7 @@ func (c *Controller) getNextWorkItem(key string) (*api.MysqlCluster, error) {
283295
if err != nil {
284296
if k8errors.IsNotFound(err) {
285297
glog.Errorf("resource not found: %s", err)
286-
return nil, fmt.Errorf("issuer %q in work queue no longer exists", key)
298+
return nil, err
287299
}
288300

289301
return nil, err

0 commit comments

Comments
 (0)