Skip to content

Commit 31e425a

Browse files
committed
Merge remote-tracking branch 'upstream/release-3.0' into appset-prod-logs-3
Signed-off-by: Alexandre Gaudreault <alexandre_gaudreault@intuit.com>
2 parents 6a9eea4 + 5c24b6b commit 31e425a

26 files changed

Lines changed: 220 additions & 107 deletions

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.4
1+
3.0.5

cmd/argocd-application-controller/commands/argocd_application_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func NewCommand() *cobra.Command {
6868
selfHealBackoffTimeoutSeconds int
6969
selfHealBackoffFactor int
7070
selfHealBackoffCapSeconds int
71+
selfHealBackoffCooldownSeconds int
7172
syncTimeout int
7273
statusProcessors int
7374
operationProcessors int
@@ -201,6 +202,7 @@ func NewCommand() *cobra.Command {
201202
time.Duration(appResyncJitter)*time.Second,
202203
time.Duration(selfHealTimeoutSeconds)*time.Second,
203204
selfHealBackoff,
205+
time.Duration(selfHealBackoffCooldownSeconds)*time.Second,
204206
time.Duration(syncTimeout)*time.Second,
205207
time.Duration(repoErrorGracePeriod)*time.Second,
206208
metricsPort,
@@ -272,6 +274,7 @@ func NewCommand() *cobra.Command {
272274
command.Flags().IntVar(&selfHealBackoffTimeoutSeconds, "self-heal-backoff-timeout-seconds", env.ParseNumFromEnv("ARGOCD_APPLICATION_CONTROLLER_SELF_HEAL_BACKOFF_TIMEOUT_SECONDS", 2, 0, math.MaxInt32), "Specifies initial timeout of exponential backoff between self heal attempts")
273275
command.Flags().IntVar(&selfHealBackoffFactor, "self-heal-backoff-factor", env.ParseNumFromEnv("ARGOCD_APPLICATION_CONTROLLER_SELF_HEAL_BACKOFF_FACTOR", 3, 0, math.MaxInt32), "Specifies factor of exponential timeout between application self heal attempts")
274276
command.Flags().IntVar(&selfHealBackoffCapSeconds, "self-heal-backoff-cap-seconds", env.ParseNumFromEnv("ARGOCD_APPLICATION_CONTROLLER_SELF_HEAL_BACKOFF_CAP_SECONDS", 300, 0, math.MaxInt32), "Specifies max timeout of exponential backoff between application self heal attempts")
277+
command.Flags().IntVar(&selfHealBackoffCooldownSeconds, "self-heal-backoff-cooldown-seconds", env.ParseNumFromEnv("ARGOCD_APPLICATION_CONTROLLER_SELF_HEAL_BACKOFF_COOLDOWN_SECONDS", 330, 0, math.MaxInt32), "Specifies period of time the app needs to stay synced before the self heal backoff can reset")
275278
command.Flags().IntVar(&syncTimeout, "sync-timeout", env.ParseNumFromEnv("ARGOCD_APPLICATION_CONTROLLER_SYNC_TIMEOUT", 0, 0, math.MaxInt32), "Specifies the timeout after which a sync would be terminated. 0 means no timeout (default 0).")
276279
command.Flags().Int64Var(&kubectlParallelismLimit, "kubectl-parallelism-limit", env.ParseInt64FromEnv("ARGOCD_APPLICATION_CONTROLLER_KUBECTL_PARALLELISM_LIMIT", 20, 0, math.MaxInt64), "Number of allowed concurrent kubectl fork/execs. Any value less than 1 means no limit.")
277280
command.Flags().BoolVar(&repoServerPlaintext, "repo-server-plaintext", env.ParseBoolFromEnv("ARGOCD_APPLICATION_CONTROLLER_REPO_SERVER_PLAINTEXT", false), "Disable TLS on connections to repo server")

commitserver/apiclient/clientset.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ package apiclient
22

33
import (
44
"fmt"
5+
"math"
6+
7+
"github.com/argoproj/argo-cd/v3/common"
8+
"github.com/argoproj/argo-cd/v3/util/env"
59

610
log "github.com/sirupsen/logrus"
711
"google.golang.org/grpc"
@@ -10,6 +14,9 @@ import (
1014
"github.com/argoproj/argo-cd/v3/util/io"
1115
)
1216

17+
// MaxGRPCMessageSize contains max grpc message size
18+
var MaxGRPCMessageSize = env.ParseNumFromEnv(common.EnvGRPCMaxSizeMB, 100, 0, math.MaxInt32) * 1024 * 1024
19+
1320
// Clientset represents commit server api clients
1421
type Clientset interface {
1522
NewCommitServerClient() (io.Closer, CommitServiceClient, error)

commitserver/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewServer(gitCredsStore git.CredsStore, metricsServer *metrics.Server) *Arg
2525

2626
// CreateGRPC creates a new gRPC server.
2727
func (a *ArgoCDCommitServer) CreateGRPC() *grpc.Server {
28-
server := grpc.NewServer()
28+
server := grpc.NewServer(grpc.MaxRecvMsgSize(apiclient.MaxGRPCMessageSize))
2929
versionpkg.RegisterVersionServiceServer(server, version.NewServer(nil, func() (bool, error) {
3030
return true, nil
3131
}))

controller/appcontroller.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"k8s.io/client-go/kubernetes"
4242
"k8s.io/client-go/tools/cache"
4343
"k8s.io/client-go/util/workqueue"
44+
"k8s.io/utils/ptr"
4445

4546
commitclient "github.com/argoproj/argo-cd/v3/commitserver/apiclient"
4647
"github.com/argoproj/argo-cd/v3/common"
@@ -133,6 +134,7 @@ type ApplicationController struct {
133134
statusRefreshJitter time.Duration
134135
selfHealTimeout time.Duration
135136
selfHealBackOff *wait.Backoff
137+
selfHealBackoffCooldown time.Duration
136138
syncTimeout time.Duration
137139
db db.ArgoDB
138140
settingsMgr *settings_util.SettingsManager
@@ -168,6 +170,7 @@ func NewApplicationController(
168170
appResyncJitter time.Duration,
169171
selfHealTimeout time.Duration,
170172
selfHealBackoff *wait.Backoff,
173+
selfHealBackoffCooldown time.Duration,
171174
syncTimeout time.Duration,
172175
repoErrorGracePeriod time.Duration,
173176
metricsPort int,
@@ -214,6 +217,7 @@ func NewApplicationController(
214217
settingsMgr: settingsMgr,
215218
selfHealTimeout: selfHealTimeout,
216219
selfHealBackOff: selfHealBackoff,
220+
selfHealBackoffCooldown: selfHealBackoffCooldown,
217221
syncTimeout: syncTimeout,
218222
clusterSharding: clusterSharding,
219223
projByNameCache: sync.Map{},
@@ -2245,17 +2249,22 @@ func (ctrl *ApplicationController) shouldSelfHeal(app *appv1.Application, alread
22452249
return true, time.Duration(0)
22462250
}
22472251

2248-
// Reset counter if the prior sync was successful OR if the revision has changed
2249-
if !alreadyAttempted || app.Status.Sync.Status == appv1.SyncStatusCodeSynced {
2252+
var timeSinceOperation *time.Duration
2253+
if app.Status.OperationState.FinishedAt != nil {
2254+
timeSinceOperation = ptr.To(time.Since(app.Status.OperationState.FinishedAt.Time))
2255+
}
2256+
2257+
// Reset counter if the prior sync was successful and the cooldown period is over OR if the revision has changed
2258+
if !alreadyAttempted || (timeSinceOperation != nil && *timeSinceOperation >= ctrl.selfHealBackoffCooldown && app.Status.Sync.Status == appv1.SyncStatusCodeSynced) {
22502259
app.Status.OperationState.Operation.Sync.SelfHealAttemptsCount = 0
22512260
}
22522261

22532262
var retryAfter time.Duration
22542263
if ctrl.selfHealBackOff == nil {
2255-
if app.Status.OperationState.FinishedAt == nil {
2264+
if timeSinceOperation == nil {
22562265
retryAfter = ctrl.selfHealTimeout
22572266
} else {
2258-
retryAfter = ctrl.selfHealTimeout - time.Since(app.Status.OperationState.FinishedAt.Time)
2267+
retryAfter = ctrl.selfHealTimeout - *timeSinceOperation
22592268
}
22602269
} else {
22612270
backOff := *ctrl.selfHealBackOff
@@ -2265,10 +2274,11 @@ func (ctrl *ApplicationController) shouldSelfHeal(app *appv1.Application, alread
22652274
for i := 0; i < steps; i++ {
22662275
delay = backOff.Step()
22672276
}
2268-
if app.Status.OperationState.FinishedAt == nil {
2277+
2278+
if timeSinceOperation == nil {
22692279
retryAfter = delay
22702280
} else {
2271-
retryAfter = delay - time.Since(app.Status.OperationState.FinishedAt.Time)
2281+
retryAfter = delay - *timeSinceOperation
22722282
}
22732283
}
22742284
return retryAfter <= 0, retryAfter

controller/appcontroller_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ func newFakeControllerWithResync(data *fakeData, appResyncPeriod time.Duration,
172172
time.Second,
173173
time.Minute,
174174
nil,
175+
time.Minute,
175176
0,
176177
time.Second*10,
177178
common.DefaultPortArgoCDMetrics,
@@ -2607,10 +2608,18 @@ func TestSelfHealExponentialBackoff(t *testing.T) {
26072608
alreadyAttempted: false,
26082609
expectedAttempts: 0,
26092610
syncStatus: v1alpha1.SyncStatusCodeOutOfSync,
2610-
}, {
2611+
}, { // backoff will not reset as finished tme isn't >= cooldown
26112612
attempts: 6,
2612-
finishedAt: nil,
2613-
expectedDuration: 0,
2613+
finishedAt: ptr.To(metav1.Now()),
2614+
expectedDuration: 120 * time.Second,
2615+
shouldSelfHeal: false,
2616+
alreadyAttempted: true,
2617+
expectedAttempts: 6,
2618+
syncStatus: v1alpha1.SyncStatusCodeSynced,
2619+
}, { // backoff will reset as finished time is >= cooldown
2620+
attempts: 40,
2621+
finishedAt: &metav1.Time{Time: time.Now().Add(-(1 * time.Minute))},
2622+
expectedDuration: -60 * time.Second,
26142623
shouldSelfHeal: true,
26152624
alreadyAttempted: true,
26162625
expectedAttempts: 0,

docs/operator-manual/server-commands/argocd-application-controller.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifests/base/application-controller-deployment/argocd-application-controller-deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ spec:
121121
name: argocd-cmd-params-cm
122122
key: controller.self.heal.backoff.cap.seconds
123123
optional: true
124+
- name: ARGOCD_APPLICATION_CONTROLLER_SELF_HEAL_BACKOFF_COOLDOWN_SECONDS
125+
valueFrom:
126+
configMapKeyRef:
127+
name: argocd-cmd-params-cm
128+
key: controller.self.heal.backoff.cooldown.seconds
129+
optional: true
124130
- name: ARGOCD_APPLICATION_CONTROLLER_SYNC_TIMEOUT
125131
valueFrom:
126132
configMapKeyRef:

manifests/base/application-controller/argocd-application-controller-statefulset.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ spec:
124124
name: argocd-cmd-params-cm
125125
key: controller.self.heal.backoff.cap.seconds
126126
optional: true
127+
- name: ARGOCD_APPLICATION_CONTROLLER_SELF_HEAL_BACKOFF_COOLDOWN_SECONDS
128+
valueFrom:
129+
configMapKeyRef:
130+
name: argocd-cmd-params-cm
131+
key: controller.self.heal.backoff.cooldown.seconds
132+
optional: true
127133
- name: ARGOCD_APPLICATION_CONTROLLER_SYNC_TIMEOUT
128134
valueFrom:
129135
configMapKeyRef:

manifests/base/commit-server/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ resources:
1212
images:
1313
- name: quay.io/argoproj/argocd
1414
newName: quay.io/argoproj/argocd
15-
newTag: v3.0.4
15+
newTag: v3.0.5

0 commit comments

Comments
 (0)