From 38984f6eba1447b18b627d00e333a498ae804aa1 Mon Sep 17 00:00:00 2001 From: Blake Pettersson Date: Sun, 3 Nov 2024 00:58:34 +0100 Subject: [PATCH] fix: rebase Signed-off-by: Blake Pettersson --- .../commands/argocd_application_controller.go | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/cmd/argocd-application-controller/commands/argocd_application_controller.go b/cmd/argocd-application-controller/commands/argocd_application_controller.go index 78b93314bf3f9..6fd1c70c301bc 100644 --- a/cmd/argocd-application-controller/commands/argocd_application_controller.go +++ b/cmd/argocd-application-controller/commands/argocd_application_controller.go @@ -9,25 +9,6 @@ import ( "syscall" "time" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/clientcmd" - - "github.com/argoproj/argo-cd/v2/util/settings" - - "github.com/argoproj/pkg/stats" - "github.com/redis/go-redis/v9" - log "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "k8s.io/client-go/kubernetes" - - "github.com/argoproj/pkg/stats" - "github.com/redis/go-redis/v9" - log "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/tools/clientcmd" - cmdutil "github.com/argoproj/argo-cd/v2/cmd/util" "github.com/argoproj/argo-cd/v2/common" "github.com/argoproj/argo-cd/v2/controller" @@ -44,8 +25,17 @@ import ( "github.com/argoproj/argo-cd/v2/util/env" "github.com/argoproj/argo-cd/v2/util/errors" kubeutil "github.com/argoproj/argo-cd/v2/util/kube" + "github.com/argoproj/argo-cd/v2/util/settings" "github.com/argoproj/argo-cd/v2/util/tls" "github.com/argoproj/argo-cd/v2/util/trace" + "github.com/argoproj/pkg/stats" + "github.com/redis/go-redis/v9" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" + "k8s.io/client-go/tools/clientcmd" ) const ( @@ -116,7 +106,10 @@ func (c *ApplicationControllerConfig) WithDefaultFlags() *ApplicationControllerC c.cmd.Flags().IntVar(&c.glogLevel, "gloglevel", 0, "Set the glog logging level") c.cmd.Flags().IntVar(&c.metricsPort, "metrics-port", common.DefaultPortArgoCDMetrics, "Start metrics server on given port") c.cmd.Flags().DurationVar(&c.metricsCacheExpiration, "metrics-cache-expiration", env.ParseDurationFromEnv("ARGOCD_APPLICATION_CONTROLLER_METRICS_CACHE_EXPIRATION", 0*time.Second, 0, math.MaxInt64), "Prometheus metrics cache expiration (disabled by default. e.g. 24h0m0s)") - c.cmd.Flags().IntVar(&c.selfHealTimeoutSeconds, "self-heal-timeout-seconds", env.ParseNumFromEnv("ARGOCD_APPLICATION_CONTROLLER_SELF_HEAL_TIMEOUT_SECONDS", 5, 0, math.MaxInt32), "Specifies timeout between application self heal attempts") + c.cmd.Flags().IntVar(&c.selfHealTimeoutSeconds, "self-heal-timeout-seconds", env.ParseNumFromEnv("ARGOCD_APPLICATION_CONTROLLER_SELF_HEAL_TIMEOUT_SECONDS", 0, 0, math.MaxInt32), "Specifies timeout between application self heal attempts") + c.cmd.Flags().IntVar(&c.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") + c.cmd.Flags().IntVar(&c.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") + c.cmd.Flags().IntVar(&c.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") c.cmd.Flags().Int64Var(&c.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.") c.cmd.Flags().BoolVar(&c.repoServerPlaintext, "repo-server-plaintext", env.ParseBoolFromEnv("ARGOCD_APPLICATION_CONTROLLER_REPO_SERVER_PLAINTEXT", false), "Disable TLS on connections to repo server") c.cmd.Flags().BoolVar(&c.repoServerStrictTLS, "repo-server-strict-tls", env.ParseBoolFromEnv("ARGOCD_APPLICATION_CONTROLLER_REPO_SERVER_STRICT_TLS", false), "Whether to use strict validation of the TLS cert presented by the repo server") @@ -233,13 +226,13 @@ func (c *ApplicationControllerConfig) CreateApplicationController(ctx context.Co kubectl := kubeutil.NewKubectl() clusterSharding, err := sharding.GetClusterSharding(kubeClient, settingsMgr, c.shardingAlgorithm, c.enableDynamicClusterDistribution) errors.CheckError(err) - var selfHealBackoff *wait.Backoff - if c.selfHealBackoffTimeoutSeconds != 0 { + var selfHealBackoff *wait.Backoff + if c.selfHealBackoffTimeoutSeconds != 0 { selfHealBackoff = &wait.Backoff{ - Duration: time.Duration(selfHealBackoffTimeoutSeconds) * time.Second, - Factor: float64(selfHealBackoffFactor), - Cap: time.Duration(selfHealBackoffCapSeconds) * time.Second, - } + Duration: time.Duration(c.selfHealBackoffTimeoutSeconds) * time.Second, + Factor: float64(c.selfHealBackoffFactor), + Cap: time.Duration(c.selfHealBackoffCapSeconds) * time.Second, + } } appController, err = controller.NewApplicationController( namespace,