@@ -67,6 +67,9 @@ const (
67
67
68
68
// EnvClusterCacheRetryUseBackoff is the env variable to control whether to use a backoff strategy with the retry during cluster cache sync
69
69
EnvClusterCacheRetryUseBackoff = "ARGOCD_CLUSTER_CACHE_RETRY_USE_BACKOFF"
70
+
71
+ // EnvClusterConnectionMonitoringInterval is the env variable to configure the cluster status monitoring interval.
72
+ EnvClusterConnectionMonitoringInterval = "ARGOCD_CLUSTER_STATUS_MONITORING_INTERVAL"
70
73
)
71
74
72
75
// GitOps engine cluster cache tuning options
98
101
99
102
// clusterCacheRetryUseBackoff specifies whether to use a backoff strategy on cluster cache sync, if retry is enabled
100
103
clusterCacheRetryUseBackoff bool = false
104
+
105
+ // clusterStatusMonitoringInterval specifies the interval used by Argo CD to monitor the cluster connection status.
106
+ clusterStatusMonitoringInterval = 10 * time .Second
101
107
)
102
108
103
109
func init () {
@@ -109,6 +115,7 @@ func init() {
109
115
clusterCacheListSemaphoreSize = env .ParseInt64FromEnv (EnvClusterCacheListSemaphore , clusterCacheListSemaphoreSize , 0 , math .MaxInt64 )
110
116
clusterCacheAttemptLimit = int32 (env .ParseNumFromEnv (EnvClusterCacheAttemptLimit , int (clusterCacheAttemptLimit ), 1 , math .MaxInt32 ))
111
117
clusterCacheRetryUseBackoff = env .ParseBoolFromEnv (EnvClusterCacheRetryUseBackoff , false )
118
+ clusterStatusMonitoringInterval = env .ParseDurationFromEnv (EnvClusterConnectionMonitoringInterval , clusterStatusMonitoringInterval , 0 , math .MaxInt64 )
112
119
}
113
120
114
121
type LiveStateCache interface {
@@ -183,7 +190,6 @@ func NewLiveStateCache(
183
190
settingsMgr : settingsMgr ,
184
191
metricsServer : metricsServer ,
185
192
clusterSharding : clusterSharding ,
186
- clusterFilter : clusterFilter ,
187
193
resourceTracking : resourceTracking ,
188
194
}
189
195
}
@@ -517,19 +523,19 @@ func (c *liveStateCache) getCluster(server string) (clustercache.ClusterCache, e
517
523
clustercache .SetRetryOptions (clusterCacheAttemptLimit , clusterCacheRetryUseBackoff , isRetryableError ),
518
524
clustercache .SetRespectRBAC (respectRBAC ),
519
525
clustercache .SetClusterStatusRetryFunc (isTransientNetworkErr ),
520
- clustercache .SetClusterConnectionInterval (10 * time . Second ),
526
+ clustercache .SetClusterConnectionInterval (clusterStatusMonitoringInterval ),
521
527
}
522
528
523
529
clusterCache = clustercache .NewClusterCache (clusterCacheConfig , clusterCacheOpts ... )
524
530
525
- // Make sure to check if the monitoring interval is disabled
526
-
527
- ctx , cancel := context .WithCancel (context .Background ())
528
- if c .clusterStatusCancel == nil {
529
- c .clusterStatusCancel = make (map [string ]context.CancelFunc )
531
+ if clusterStatusMonitoringInterval != 0 {
532
+ ctx , cancel := context .WithCancel (context .Background ())
533
+ if c .clusterStatusCancel == nil {
534
+ c .clusterStatusCancel = make (map [string ]context.CancelFunc )
535
+ }
536
+ c .clusterStatusCancel [server ] = cancel
537
+ clusterCache .StartClusterConnectionStatusMonitoring (ctx )
530
538
}
531
- c .clusterStatusCancel [server ] = cancel
532
- clusterCache .StartClusterConnectionStatusMonitoring (ctx )
533
539
534
540
_ = clusterCache .OnResourceUpdated (func (newRes * clustercache.Resource , oldRes * clustercache.Resource , namespaceResources map [kube.ResourceKey ]* clustercache.Resource ) {
535
541
toNotify := make (map [string ]bool )
0 commit comments