1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

fix: remove explicit wait for cache sync (#4791)

Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>

Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>
This commit is contained in:
Charles-Edouard Brétéché 2022-10-03 16:44:41 +02:00 committed by GitHub
parent 5f3411e588
commit 59f11f08b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 18 deletions

View file

@ -28,8 +28,6 @@ type Controller interface {
type controller struct {
renewer *tls.CertRenewer
secretLister corev1listers.SecretLister
// secretSynced returns true if the secret shared informer has synced at least once
secretSynced cache.InformerSynced
secretQueue chan bool
}
@ -37,7 +35,6 @@ func NewController(secretInformer corev1informers.SecretInformer, certRenewer *t
manager := &controller{
renewer: certRenewer,
secretLister: secretInformer.Lister(),
secretSynced: secretInformer.Informer().HasSynced,
secretQueue: make(chan bool, 1),
}
secretInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{

View file

@ -10,7 +10,6 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
corev1informers "k8s.io/client-go/informers/core/v1"
corev1listers "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
)
@ -26,9 +25,6 @@ type controller struct {
// listers
configmapLister corev1listers.ConfigMapLister
// configmapSynced returns true if the configmap shared informer has synced at least once
configmapSynced cache.InformerSynced
// queue
queue workqueue.RateLimitingInterface
}
@ -39,14 +35,12 @@ func NewController(configuration config.Configuration, configmapInformer corev1i
configmapLister: configmapInformer.Lister(),
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), controllerName),
}
c.configmapSynced = configmapInformer.Informer().HasSynced
controllerutils.AddDefaultEventHandlers(logger.V(3), configmapInformer.Informer(), c.queue)
return &c
}
func (c *controller) Run(ctx context.Context, workers int) {
controllerutils.Run(ctx, controllerName, logger.V(3), c.queue, workers, maxRetries, c.reconcile, c.configmapSynced)
controllerutils.Run(ctx, controllerName, logger.V(3), c.queue, workers, maxRetries, c.reconcile)
}
func (c *controller) reconcile(ctx context.Context, logger logr.Logger, key, namespace, name string) error {

View file

@ -35,11 +35,6 @@ type controller struct {
cpolLister kyvernov1listers.ClusterPolicyLister
polLister kyvernov1listers.PolicyLister
// cpolSynced returns true if the cluster policy shared informer has synced at least once
cpolSynced cache.InformerSynced
// polSynced returns true if the policy shared informer has synced at least once
polSynced cache.InformerSynced
// queue
queue workqueue.RateLimitingInterface
}
@ -49,8 +44,6 @@ func NewController(pcache pcache.Cache, cpolInformer kyvernov1informers.ClusterP
cache: pcache,
cpolLister: cpolInformer.Lister(),
polLister: polInformer.Lister(),
cpolSynced: cpolInformer.Informer().HasSynced,
polSynced: polInformer.Informer().HasSynced,
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), controllerName),
}
controllerutils.AddDefaultEventHandlers(logger.V(3), cpolInformer.Informer(), c.queue)
@ -88,7 +81,7 @@ func (c *controller) WarmUp() error {
}
func (c *controller) Run(ctx context.Context, workers int) {
controllerutils.Run(ctx, controllerName, logger.V(3), c.queue, workers, maxRetries, c.reconcile, c.cpolSynced, c.polSynced)
controllerutils.Run(ctx, controllerName, logger.V(3), c.queue, workers, maxRetries, c.reconcile)
}
func (c *controller) reconcile(ctx context.Context, logger logr.Logger, key, namespace, name string) error {