mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 11:28:58 +00:00
Fix logspam in leaderelection controller.
If the reconcileElectionStep function returns `noRequeue, nil`, it causes log
spam from apiserver. This is because HandleErrorWithContext regardless of
error value. Skip logging if error is nil.
Also, tag the log message with the involved lease object name.
```
...
{"ts":1773796037662.8264,"logger":"UnhandledError","caller":"leaderelection/leaderelection_controller.go:169","msg":"Failed to reconcile election step"}
{"ts":1773796038472.465,"logger":"UnhandledError","caller":"leaderelection/leaderelection_controller.go:169","msg":"Failed to reconcile election step"}
...
```
This commit is contained in:
@@ -166,7 +166,9 @@ func (c *Controller) processNextElectionItem(ctx context.Context) bool {
|
||||
}
|
||||
|
||||
intervalForRequeue, err := c.reconcileElectionStep(ctx, key)
|
||||
utilruntime.HandleErrorWithContext(ctx, err, "Failed to reconcile election step")
|
||||
if err != nil { // HandleErrorWithContext logs regardless of error value, filter out nil err.
|
||||
utilruntime.HandleErrorWithContext(ctx, err, "Failed to reconcile election step", "key", key)
|
||||
}
|
||||
if intervalForRequeue != noRequeue {
|
||||
defer c.queue.AddAfter(key, intervalForRequeue)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user