mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-14 19:58:45 +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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -172,9 +173,12 @@ func (c *controller) updateDynamicWatchers(ctx context.Context) error {
|
||||||
c.notify(uid, gvk, hashes[uid])
|
c.notify(uid, gvk, hashes[uid])
|
||||||
}
|
}
|
||||||
logger.Info("start watcher ...", "gvr", gvr, "resourceVersion", resourceVersion)
|
logger.Info("start watcher ...", "gvr", gvr, "resourceVersion", resourceVersion)
|
||||||
|
|
||||||
watchFunc := func(options metav1.ListOptions) (watch.Interface, error) {
|
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})
|
watchInterface, err := watchTools.NewRetryWatcher(resourceVersion, &cache.ListWatch{WatchFunc: watchFunc})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue