Skip to content

Commit

Permalink
add cacheSyncPeriod option to ClusterCacheTracker
Browse files Browse the repository at this point in the history
  • Loading branch information
ykakarap authored and k8s-infra-cherrypick-robot committed Oct 2, 2024
1 parent 1558c7a commit 09d49d4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion controllers/remote/cluster_cache_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 09d49d4

Please sign in to comment.