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