Skip to content

Commit cd970a4

Browse files
MikeSpreitzerk8s-publishing-bot
authored andcommitted
Finish switching to utilruntime.HandleErrorWithContext
Signed-off-by: Mike Spreitzer <[email protected]> Kubernetes-commit: fdbf0bbb2d85c3095fdc9625620648fb861fce6a
1 parent 6e60f34 commit cd970a4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

controller.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {
225225
// there was a failure so be sure to report it. This method allows for
226226
// pluggable error handling which can be used for things like
227227
// cluster-monitoring.
228-
utilruntime.HandleErrorWithContext(ctx, err, "error syncing; requeuing", "objectReference", objRef)
228+
utilruntime.HandleErrorWithContext(ctx, err, "Error syncing; requeuing for later retry", "objectReference", objRef)
229229
// since we failed, we should requeue the item to work on later. This
230230
// method will add a backoff to avoid hotlooping on particular items
231231
// (they're probably still not going to work right away) and overall
@@ -247,7 +247,7 @@ func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName
247247
// The Foo resource may no longer exist, in which case we stop
248248
// processing.
249249
if errors.IsNotFound(err) {
250-
utilruntime.HandleError(fmt.Errorf("foo '%#v' in work queue no longer exists", objectRef))
250+
utilruntime.HandleErrorWithContext(ctx, err, "Foo referenced by item in work queue no longer exists", "objectReference", objectRef)
251251
return nil
252252
}
253253

@@ -259,7 +259,7 @@ func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName
259259
// We choose to absorb the error here as the worker would requeue the
260260
// resource otherwise. Instead, the next time the resource is updated
261261
// the resource will be queued again.
262-
utilruntime.HandleError(fmt.Errorf("%#v: deployment name must be specified", objectRef))
262+
utilruntime.HandleErrorWithContext(ctx, nil, "Deployment name missing from object reference", "objectReference", objectRef)
263263
return nil
264264
}
265265

@@ -349,12 +349,16 @@ func (c *Controller) handleObject(obj interface{}) {
349349
if object, ok = obj.(metav1.Object); !ok {
350350
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
351351
if !ok {
352-
utilruntime.HandleError(fmt.Errorf("error decoding object, invalid type"))
352+
// If the object value is not too big and does not contain sensitive information then
353+
// it may be useful to include it.
354+
utilruntime.HandleErrorWithContext(context.Background(), nil, "Error decoding object, invalid type", "type", fmt.Sprintf("%T", obj))
353355
return
354356
}
355357
object, ok = tombstone.Obj.(metav1.Object)
356358
if !ok {
357-
utilruntime.HandleError(fmt.Errorf("error decoding object tombstone, invalid type"))
359+
// If the object value is not too big and does not contain sensitive information then
360+
// it may be useful to include it.
361+
utilruntime.HandleErrorWithContext(context.Background(), nil, "Error decoding object tombstone, invalid type", "type", fmt.Sprintf("%T", tombstone.Obj))
358362
return
359363
}
360364
logger.V(4).Info("Recovered deleted object", "resourceName", object.GetName())

0 commit comments

Comments
 (0)