Skip to content

Commit

Permalink
[local] Wait for initial cache to sync before starting autoscaling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
domenicbozzuto committed Oct 23, 2024
1 parent 7d051cc commit 6e35d9c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 6e35d9c

Please sign in to comment.