mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-06 03:36:26 +00:00
move WaitForCacheSync to the sharedInformer package
Signed-off-by: Yassine TIJANI <ytijani@vmware.com> Kubernetes-commit: 7e4c3096fe71afc6a23c273b3309ed5db7289d8c
This commit is contained in:
parent
6ddd067b15
commit
7ee6383729
@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/util/runtime"
|
"k8s.io/apimachinery/pkg/util/runtime"
|
||||||
|
16
tools/cache/shared_informer.go
vendored
16
tools/cache/shared_informer.go
vendored
@ -190,8 +190,24 @@ const (
|
|||||||
initialBufferSize = 1024
|
initialBufferSize = 1024
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// WaitForNamedCacheSync is a wrapper around WaitForCacheSync that generates log messages
|
||||||
|
// indicating that the caller identified by name is waiting for syncs, followed by
|
||||||
|
// either a successful or failed sync.
|
||||||
|
func WaitForNamedCacheSync(controllerName string, stopCh <-chan struct{}, cacheSyncs ...InformerSynced) bool {
|
||||||
|
klog.Infof("Waiting for caches to sync for %s", controllerName)
|
||||||
|
|
||||||
|
if !WaitForCacheSync(stopCh, cacheSyncs...) {
|
||||||
|
utilruntime.HandleError(fmt.Errorf("unable to sync caches for %s", controllerName))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
klog.Infof("Caches are synced for %s ", controllerName)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// WaitForCacheSync waits for caches to populate. It returns true if it was successful, false
|
// WaitForCacheSync waits for caches to populate. It returns true if it was successful, false
|
||||||
// if the controller should shutdown
|
// if the controller should shutdown
|
||||||
|
// callers should prefer WaitForNamedCacheSync()
|
||||||
func WaitForCacheSync(stopCh <-chan struct{}, cacheSyncs ...InformerSynced) bool {
|
func WaitForCacheSync(stopCh <-chan struct{}, cacheSyncs ...InformerSynced) bool {
|
||||||
err := wait.PollUntil(syncedPollPeriod,
|
err := wait.PollUntil(syncedPollPeriod,
|
||||||
func() (bool, error) {
|
func() (bool, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user