From 09d49d41cacdb908f4218a84364b88688ba4cbe4 Mon Sep 17 00:00:00 2001 From: Yuvaraj Kakaraparthi Date: Tue, 1 Oct 2024 13:17:41 -0700 Subject: [PATCH] add cacheSyncPeriod option to ClusterCacheTracker --- controllers/remote/cluster_cache_tracker.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/controllers/remote/cluster_cache_tracker.go b/controllers/remote/cluster_cache_tracker.go index f5ecb5ada259..2ca2d9d67b3b 100644 --- a/controllers/remote/cluster_cache_tracker.go +++ b/controllers/remote/cluster_cache_tracker.go @@ -69,7 +69,8 @@ var ErrClusterLocked = errors.New("cluster is locked already") type ClusterCacheTracker struct { log logr.Logger - cacheByObject map[client.Object]cache.ByObject + cacheByObject map[client.Object]cache.ByObject + cacheSyncPeriod *time.Duration clientUncachedObjects []client.Object clientQPS float32 @@ -120,6 +121,9 @@ type ClusterCacheTrackerOptions struct { // CacheByObject restricts the cache's ListWatch to the desired fields per GVK at the specified object. CacheByObject map[client.Object]cache.ByObject + // CacheSyncPeriod is the syncPeriod used by the remote cluster cache. + CacheSyncPeriod *time.Duration + // ClientUncachedObjects instructs the Client to never cache the following objects, // it'll instead query the API server directly. // Defaults to never caching ConfigMap and Secret if not set. @@ -197,6 +201,7 @@ func NewClusterCacheTracker(manager ctrl.Manager, options ClusterCacheTrackerOpt log: *options.Log, clientUncachedObjects: options.ClientUncachedObjects, cacheByObject: options.CacheByObject, + cacheSyncPeriod: options.CacheSyncPeriod, clientQPS: options.ClientQPS, clientBurst: options.ClientBurst, client: manager.GetClient(), @@ -492,6 +497,7 @@ func (t *ClusterCacheTracker) createCachedClient(ctx context.Context, config *re Scheme: t.scheme, Mapper: mapper, ByObject: t.cacheByObject, + SyncPeriod: t.cacheSyncPeriod, } remoteCache, err := cache.New(config, cacheOptions) if err != nil {