Documentation ¶
Overview ¶
Package synced provides tools for tracking if k8s resources have been initially sychronized with the k8s apiserver.
Index ¶
- Variables
- func AgentCRDResourceNames() []string
- func AllCiliumCRDResourceNames() []string
- func CRDResourceName(crd string) string
- func ClusterMeshAPIServerResourceNames() []string
- func SyncCRDs(ctx context.Context, clientset client.Clientset, crdNames []string, ...) error
- type APIGroups
- type CRDSync
- type CRDSyncResourceNames
- type CacheStatus
- type Resources
- func (r *Resources) BlockWaitGroupToSyncResources(stop <-chan struct{}, swg *lock.StoppableWaitGroup, ...)
- func (r *Resources) CancelWaitGroupToSyncResources(resourceName string)
- func (r *Resources) SetEventTimestamp(resource string)
- func (r *Resources) WaitForCacheSync(resourceNames ...string)
- func (r *Resources) WaitForCacheSyncWithTimeout(timeout time.Duration, resourceNames ...string) error
Constants ¶
This section is empty.
Variables ¶
var CRDSyncCell = cell.Module( "k8s-synced-crdsync", "Provides promise for waiting for CRD to have been synchronized", cell.Provide(newCRDSyncPromise), )
var Cell = cell.Module( "k8s-synced", "Provides types for internal K8s resource synchronization", cell.Provide(func() *APIGroups { return new(APIGroups) }), cell.Provide(func(params syncedParams) *Resources { return &Resources{ CacheStatus: params.CacheStatus, } }), cell.Provide(func() CacheStatus { return make(CacheStatus) }), )
var ErrCRDSyncDisabled = errors.New("CRDSync promise is disabled")
var RejectedCRDSyncPromise = func() promise.Promise[CRDSync] { crdSyncResolver, crdSyncPromise := promise.New[CRDSync]() crdSyncResolver.Reject(ErrCRDSyncDisabled) return crdSyncPromise }
RejectedCRDSyncPromise can be used in hives that do not provide the CRDSync promise.
Functions ¶
func AgentCRDResourceNames ¶
func AgentCRDResourceNames() []string
AgentCRDResourceNames returns a list of all CRD resource names the Cilium agent needs to wait to be registered before initializing any k8s watchers.
func AllCiliumCRDResourceNames ¶
func AllCiliumCRDResourceNames() []string
AllCiliumCRDResourceNames returns a list of all Cilium CRD resource names that the cilium operator or testsuite may register.
func CRDResourceName ¶
func ClusterMeshAPIServerResourceNames ¶
func ClusterMeshAPIServerResourceNames() []string
ClusterMeshAPIServerResourceNames returns a list of all CRD resource names the clustermesh-apiserver needs to wait to be registered before initializing any k8s watchers.
func SyncCRDs ¶
func SyncCRDs(ctx context.Context, clientset client.Clientset, crdNames []string, rs *Resources, ag *APIGroups) error
SyncCRDs will sync Cilium CRDs to ensure that they have all been installed inside the K8s cluster. These CRDs are added by the Cilium Operator. This function will block until it finds all the CRDs or if a timeout occurs.
Types ¶
type APIGroups ¶
APIGroups is a lockable map to hold which k8s API Groups we have enabled/in-use Note: We can replace it with a Go 1.9 map once we require that version
type CRDSync ¶ added in v1.16.0
type CRDSync struct{}
CRDSync is an empty type used for promise.Promise. If SyncCRDs() fails, the error is passed via promise Reject to the result of the promise Await() call.
type CRDSyncResourceNames ¶ added in v1.16.0
type CRDSyncResourceNames []string
CRDSyncResourceNames is a slice of CRD resource names CRDSync promise waits for
type CacheStatus ¶ added in v1.16.0
type CacheStatus chan struct{}
CacheStatus allows waiting for k8s caches to synchronize.
func (CacheStatus) Synchronized ¶ added in v1.16.0
func (cs CacheStatus) Synchronized() bool
Sychronized returns true if caches have been synchronized at least once.
Returns true for an uninitialized CacheStatus.
type Resources ¶
type Resources struct { CacheStatus CacheStatus lock.RWMutex // contains filtered or unexported fields }
Resources maps resource names to channels that are closed upon initial sync with k8s.
func (*Resources) BlockWaitGroupToSyncResources ¶
func (r *Resources) BlockWaitGroupToSyncResources( stop <-chan struct{}, swg *lock.StoppableWaitGroup, hasSyncedFunc cache.InformerSynced, resourceName string, )
BlockWaitGroupToSyncResources ensures that anything which waits on waitGroup waits until all objects of the specified resource stored in Kubernetes are received by the informer and processed by controller. Fatally exits if syncing these initial objects fails. If the given stop channel is closed, it does not fatal. Once the k8s caches are synced against k8s, k8sCacheSynced is also closed.
func (*Resources) CancelWaitGroupToSyncResources ¶
func (*Resources) SetEventTimestamp ¶
func (*Resources) WaitForCacheSync ¶
WaitForCacheSync waits for all K8s resources represented by resourceNames to have their K8s caches synchronized.
func (*Resources) WaitForCacheSyncWithTimeout ¶
func (r *Resources) WaitForCacheSyncWithTimeout(timeout time.Duration, resourceNames ...string) error
WaitForCacheSyncWithTimeout waits for K8s resources represented by resourceNames to be synced. For every resource type, if an event happens after starting the wait, the timeout will be pushed out to be the time of the last event plus the timeout duration.