From 725dd4d30ee0995c27b1919729d2ca605774b784 Mon Sep 17 00:00:00 2001 From: Zach Aller Date: Thu, 5 Oct 2023 08:14:05 -0600 Subject: [PATCH] fix: sync notification controller configmaps/secrets first (#3075) sync notification controller configmaps/secrets first before starting other informers Signed-off-by: zachaller --- controller/controller.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index 5429cfe743..afe4bc769b 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -463,6 +463,12 @@ func (c *Manager) startLeading(ctx context.Context, rolloutThreadiness, serviceT // Start the informer factories to begin populating the informer caches log.Info("Starting Controllers") + c.notificationConfigMapInformerFactory.Start(ctx.Done()) + c.notificationSecretInformerFactory.Start(ctx.Done()) + if ok := cache.WaitForCacheSync(ctx.Done(), c.configMapSynced, c.secretSynced); !ok { + log.Fatalf("failed to wait for configmap/secret caches to sync, exiting") + } + // notice that there is no need to run Start methods in a separate goroutine. (i.e. go kubeInformerFactory.Start(stopCh) // Start method is non-blocking and runs all registered informers in a dedicated goroutine. c.dynamicInformerFactory.Start(ctx.Done()) @@ -471,9 +477,6 @@ func (c *Manager) startLeading(ctx context.Context, rolloutThreadiness, serviceT } c.kubeInformerFactory.Start(ctx.Done()) - c.notificationConfigMapInformerFactory.Start(ctx.Done()) - c.notificationSecretInformerFactory.Start(ctx.Done()) - c.jobInformerFactory.Start(ctx.Done()) // Check if Istio installed on cluster before starting dynamicInformerFactory