1
0
Fork 0
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:
Charles-Edouard Brétéché 2022-11-23 18:48:50 +01:00 committed by GitHub
parent 48ebe0f4c6
commit 3766f6e6cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {