Skip to content

Commit baa2707

Browse files
authored
Merge pull request #1196 from vincepri/never-stop-hope
🐛 Controller reconcileHandler shouldn't stop a worker on error
2 parents a6e9977 + b4a0212 commit baa2707

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pkg/internal/controller/controller.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,11 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {
232232
ctrlmetrics.ActiveWorkers.WithLabelValues(c.Name).Add(1)
233233
defer ctrlmetrics.ActiveWorkers.WithLabelValues(c.Name).Add(-1)
234234

235-
return c.reconcileHandler(ctx, obj)
235+
c.reconcileHandler(ctx, obj)
236+
return true
236237
}
237238

238-
func (c *Controller) reconcileHandler(ctx context.Context, obj interface{}) bool {
239+
func (c *Controller) reconcileHandler(ctx context.Context, obj interface{}) {
239240
// Update metrics after processing each item
240241
reconcileStartTS := time.Now()
241242
defer func() {
@@ -251,7 +252,7 @@ func (c *Controller) reconcileHandler(ctx context.Context, obj interface{}) bool
251252
c.Queue.Forget(obj)
252253
c.Log.Error(nil, "Queue item was not a Request", "type", fmt.Sprintf("%T", obj), "value", obj)
253254
// Return true, don't take a break
254-
return true
255+
return
255256
}
256257

257258
log := c.Log.WithValues("name", req.Name, "namespace", req.Namespace)
@@ -263,7 +264,7 @@ func (c *Controller) reconcileHandler(ctx context.Context, obj interface{}) bool
263264
c.Queue.AddRateLimited(req)
264265
ctrlmetrics.ReconcileErrors.WithLabelValues(c.Name).Inc()
265266
ctrlmetrics.ReconcileTotal.WithLabelValues(c.Name, "error").Inc()
266-
return false
267+
return
267268
} else if result.RequeueAfter > 0 {
268269
// The result.RequeueAfter request will be lost, if it is returned
269270
// along with a non-nil error. But this is intended as
@@ -272,20 +273,18 @@ func (c *Controller) reconcileHandler(ctx context.Context, obj interface{}) bool
272273
c.Queue.Forget(obj)
273274
c.Queue.AddAfter(req, result.RequeueAfter)
274275
ctrlmetrics.ReconcileTotal.WithLabelValues(c.Name, "requeue_after").Inc()
275-
return true
276+
return
276277
} else if result.Requeue {
277278
c.Queue.AddRateLimited(req)
278279
ctrlmetrics.ReconcileTotal.WithLabelValues(c.Name, "requeue").Inc()
279-
return true
280+
return
280281
}
281282

282283
// Finally, if no error occurs we Forget this item so it does not
283284
// get queued again until another change happens.
284285
c.Queue.Forget(obj)
285286

286287
ctrlmetrics.ReconcileTotal.WithLabelValues(c.Name, "success").Inc()
287-
// Return true, don't take a break
288-
return true
289288
}
290289

291290
// InjectFunc implement SetFields.Injector

0 commit comments

Comments
 (0)