From 6e35d9c0397c99abb0a26a1969e39b12de0e12d3 Mon Sep 17 00:00:00 2001 From: "dom.bozzuto" Date: Mon, 21 Oct 2024 14:30:39 -0400 Subject: [PATCH] [local] Wait for initial cache to sync before starting autoscaling Adds a call to WaitForCacheSync after the sharedInformerFactory has been started; This will help remediate against cases where the API server is (partially) unavailable and prevent empty, unsynced cache data from being served to consumers. --- cluster-autoscaler/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cluster-autoscaler/main.go b/cluster-autoscaler/main.go index 888c34ac2c2b..71df2f221df9 100644 --- a/cluster-autoscaler/main.go +++ b/cluster-autoscaler/main.go @@ -608,7 +608,11 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter // additional informers might have been registered in the factory during NewAutoscaler. stop := make(chan struct{}) informerFactory.Start(stop) + klog.V(1).Info("Started shared informer factory, waiting for initial cache sync") + informerStartTime := time.Now() + informerFactory.WaitForCacheSync(stop) + klog.V(1).Infof("Shared informer factory finished initial sync, took %v", time.Since(informerStartTime)) return autoscaler, nil }