Skip to content

Commit

Permalink
Merge pull request #11249 from k8s-infra-cherrypick-robot/cherry-pick…
Browse files Browse the repository at this point in the history
…-11248-to-release-1.8

[release-1.8] 🌱 add cacheSyncPeriod option to ClusterCacheTracker
  • Loading branch information
k8s-ci-robot authored Oct 2, 2024
2 parents 1558c7a + 09d49d4 commit 9a51347
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 9a51347

Please sign in to comment.