Skip to content

Commit 7f52294

Browse files
committed
Make monitoring interval configurable
Signed-off-by: Chetan Banavikalmutt <[email protected]>
1 parent 66d60fd commit 7f52294

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

controller/cache/cache.go

+15-9
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ const (
6767

6868
// EnvClusterCacheRetryUseBackoff is the env variable to control whether to use a backoff strategy with the retry during cluster cache sync
6969
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"
7073
)
7174

7275
// GitOps engine cluster cache tuning options
@@ -98,6 +101,9 @@ var (
98101

99102
// clusterCacheRetryUseBackoff specifies whether to use a backoff strategy on cluster cache sync, if retry is enabled
100103
clusterCacheRetryUseBackoff bool = false
104+
105+
// clusterStatusMonitoringInterval specifies the interval used by Argo CD to monitor the cluster connection status.
106+
clusterStatusMonitoringInterval = 10 * time.Second
101107
)
102108

103109
func init() {
@@ -109,6 +115,7 @@ func init() {
109115
clusterCacheListSemaphoreSize = env.ParseInt64FromEnv(EnvClusterCacheListSemaphore, clusterCacheListSemaphoreSize, 0, math.MaxInt64)
110116
clusterCacheAttemptLimit = int32(env.ParseNumFromEnv(EnvClusterCacheAttemptLimit, int(clusterCacheAttemptLimit), 1, math.MaxInt32))
111117
clusterCacheRetryUseBackoff = env.ParseBoolFromEnv(EnvClusterCacheRetryUseBackoff, false)
118+
clusterStatusMonitoringInterval = env.ParseDurationFromEnv(EnvClusterConnectionMonitoringInterval, clusterStatusMonitoringInterval, 0, math.MaxInt64)
112119
}
113120

114121
type LiveStateCache interface {
@@ -183,7 +190,6 @@ func NewLiveStateCache(
183190
settingsMgr: settingsMgr,
184191
metricsServer: metricsServer,
185192
clusterSharding: clusterSharding,
186-
clusterFilter: clusterFilter,
187193
resourceTracking: resourceTracking,
188194
}
189195
}
@@ -517,19 +523,19 @@ func (c *liveStateCache) getCluster(server string) (clustercache.ClusterCache, e
517523
clustercache.SetRetryOptions(clusterCacheAttemptLimit, clusterCacheRetryUseBackoff, isRetryableError),
518524
clustercache.SetRespectRBAC(respectRBAC),
519525
clustercache.SetClusterStatusRetryFunc(isTransientNetworkErr),
520-
clustercache.SetClusterConnectionInterval(10 * time.Second),
526+
clustercache.SetClusterConnectionInterval(clusterStatusMonitoringInterval),
521527
}
522528

523529
clusterCache = clustercache.NewClusterCache(clusterCacheConfig, clusterCacheOpts...)
524530

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)
530538
}
531-
c.clusterStatusCancel[server] = cancel
532-
clusterCache.StartClusterConnectionStatusMonitoring(ctx)
533539

534540
_ = clusterCache.OnResourceUpdated(func(newRes *clustercache.Resource, oldRes *clustercache.Resource, namespaceResources map[kube.ResourceKey]*clustercache.Resource) {
535541
toNotify := make(map[string]bool)

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ require (
295295
)
296296

297297
replace (
298-
github.com/argoproj/gitops-engine => ../gitops-engine
298+
github.com/argoproj/gitops-engine => github.com/chetan-rns/gitops-engine v0.1.3-0.20240404103429-cea6dcc9ec66
299299
// https://github.com/golang/go/issues/33546#issuecomment-519656923
300300
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
301301

go.sum

+6-2
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb
695695
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
696696
github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU=
697697
github.com/appscode/go v0.0.0-20191119085241-0887d8ec2ecc/go.mod h1:OawnOmAL4ZX3YaPdN+8HTNwBveT1jMsqP74moa9XUbE=
698-
github.com/argoproj/notifications-engine v0.4.1-0.20230905144632-9dcecdc3eebf h1:4wliaBwd6iKvT/5huDTJntaYtTSdwPLs00SOQwDSK6A=
699-
github.com/argoproj/notifications-engine v0.4.1-0.20230905144632-9dcecdc3eebf/go.mod h1:TuK0BNKo34DIUOyCCGOB9ij+smGCxeCgt9ZB+0fMWno=
698+
github.com/argoproj/notifications-engine v0.4.1-0.20240403133627-f48567108f01 h1:/V8+HM0VPPTrdjTwUrkIj5a+SjaU//tJwfIXJ1QAOvg=
699+
github.com/argoproj/notifications-engine v0.4.1-0.20240403133627-f48567108f01/go.mod h1:N0A4sEws2soZjEpY4hgZpQS8mRIEw6otzwfkgc3g9uQ=
700700
github.com/argoproj/pkg v0.13.7-0.20230626144333-d56162821bd1 h1:qsHwwOJ21K2Ao0xPju1sNuqphyMnMYkyB3ZLoLtxWpo=
701701
github.com/argoproj/pkg v0.13.7-0.20230626144333-d56162821bd1/go.mod h1:CZHlkyAD1/+FbEn6cB2DQTj48IoLGvEYsWEvtzP3238=
702702
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
@@ -786,6 +786,8 @@ github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNS
786786
github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA=
787787
github.com/chainguard-dev/git-urls v1.0.2 h1:pSpT7ifrpc5X55n4aTTm7FFUE+ZQHKiqpiwNkJrVcKQ=
788788
github.com/chainguard-dev/git-urls v1.0.2/go.mod h1:rbGgj10OS7UgZlbzdUQIQpT0k/D4+An04HJY7Ol+Y/o=
789+
github.com/chetan-rns/gitops-engine v0.1.3-0.20240404103429-cea6dcc9ec66 h1:BOFozSr3QU9BpcC91A9bNLo2CQjpig0Yf65cg8dyO6w=
790+
github.com/chetan-rns/gitops-engine v0.1.3-0.20240404103429-cea6dcc9ec66/go.mod h1:gWE8uROi7hIkWGNAVM+8FWkMfo0vZ03SLx/aFw/DBzg=
789791
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
790792
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
791793
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
@@ -1101,6 +1103,8 @@ github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9
11011103
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
11021104
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
11031105
github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
1106+
github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0=
1107+
github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E=
11041108
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
11051109
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
11061110
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=

0 commit comments

Comments
 (0)