Skip to content

Commit eac2226

Browse files
committed
Add back error logging for Reconcile implementation
This https://github.com/kubernetes-sigs/controller-runtime/pull/1054/files#diff-3f86588ef108e53ef346d3223ca106ccaa8efe72cb1055489665d7675f3da7b4R242 degaded the log level for the Reconcile implementation. Then this completely remove the error logging https://github.com/kubernetes-sigs/controller-runtime/pull/1096/files#diff-3f86588ef108e53ef346d3223ca106ccaa8efe72cb1055489665d7675f3da7b4L242 When developing new controllers feels counterintuitive that controller runtime eats the error returned by the Reconcile implementation. This proposes to log the error and let developers to create an additional log on the implementation if they choose to.
1 parent af24f3b commit eac2226

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

TMP-LOGGING.md

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ It's acceptable to log call `log.Error` with a nil error object. This
9090
conveys that an error occurred in some capacity, but that no actual
9191
`error` object was involved.
9292

93+
Errors returned by the `Reconcile` implementation of the `Reconciler` interface are commonly logged as a `Reconciler error`.
94+
It's a developer choice to create an additional error log in the `Reconcile` implementation so a more specific file name and line for the error are returned.
95+
9396
## Logging messages
9497

9598
- Don't put variable content in your messages -- use key-value pairs for

pkg/internal/controller/controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ func (c *Controller) reconcileHandler(ctx context.Context, obj interface{}) {
264264
c.Queue.AddRateLimited(req)
265265
ctrlmetrics.ReconcileErrors.WithLabelValues(c.Name).Inc()
266266
ctrlmetrics.ReconcileTotal.WithLabelValues(c.Name, "error").Inc()
267+
log.Error(err, "Reconciler error")
267268
return
268269
} else if result.RequeueAfter > 0 {
269270
// The result.RequeueAfter request will be lost, if it is returned

0 commit comments

Comments
 (0)