mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
fix: log watcher error in reports controller (#5449)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Co-authored-by: Prateek Pandey <prateek.pandey@nirmata.com>
This commit is contained in:
parent
48ebe0f4c6
commit
3766f6e6cf
1 changed files with 6 additions and 2 deletions
|
@ -2,6 +2,7 @@ package resource
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -172,9 +173,12 @@ func (c *controller) updateDynamicWatchers(ctx context.Context) error {
|
|||
c.notify(uid, gvk, hashes[uid])
|
||||
}
|
||||
logger.Info("start watcher ...", "gvr", gvr, "resourceVersion", resourceVersion)
|
||||
|
||||
watchFunc := func(options metav1.ListOptions) (watch.Interface, error) {
|
||||
return c.client.GetDynamicInterface().Resource(gvr).Watch(ctx, options)
|
||||
watch, err := c.client.GetDynamicInterface().Resource(gvr).Watch(ctx, options)
|
||||
if err != nil && !errors.Is(err, context.Canceled) {
|
||||
logger.Error(err, "failed to watch", "gvr", gvr)
|
||||
}
|
||||
return watch, err
|
||||
}
|
||||
watchInterface, err := watchTools.NewRetryWatcher(resourceVersion, &cache.ListWatch{WatchFunc: watchFunc})
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue