mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-27 07:28:14 +00:00
Check cache is synced first before sleeping
If a cache was already synced, cache.WaitForCacheSync would always take 100ms to complete because the PollUntil method will sleep first before checking the condition. Switching to PollImmediateUntil will ensure already synced caches will return immediately. For code that has, for example, 20 informers, the time to check the cache was in sync would take at least 2 seconds, but with this change it can be as fast as you can actually load the data. Signed-off-by: Darren Shepherd <darren@rancher.com> Kubernetes-commit: 8a58f332dd62b68ae22c67585002defe6aeb4b04
This commit is contained in:
parent
86c133ba28
commit
6d3b14b468
2
tools/cache/shared_informer.go
vendored
2
tools/cache/shared_informer.go
vendored
@ -209,7 +209,7 @@ func WaitForNamedCacheSync(controllerName string, stopCh <-chan struct{}, cacheS
|
||||
// if the controller should shutdown
|
||||
// callers should prefer WaitForNamedCacheSync()
|
||||
func WaitForCacheSync(stopCh <-chan struct{}, cacheSyncs ...InformerSynced) bool {
|
||||
err := wait.PollUntil(syncedPollPeriod,
|
||||
err := wait.PollImmediateUntil(syncedPollPeriod,
|
||||
func() (bool, error) {
|
||||
for _, syncFunc := range cacheSyncs {
|
||||
if !syncFunc() {
|
||||
|
Loading…
Reference in New Issue
Block a user