From d9b2d5b70956fae06896819e79ef3d7f1fdb1431 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Mon, 27 Nov 2023 23:35:43 +0200 Subject: [PATCH] resolve PR comments --- Procfile | 2 +- .../commands/event_reporter_server.go | 13 ++++++------- common/common.go | 2 +- controller/sync.go | 2 +- event_reporter/metrics/metrics.go | 2 -- event_reporter/server.go | 4 ++-- event_reporter/sharding/sharding.go | 1 - .../base/event-reporter/event-reporter-service.yaml | 2 +- .../event-reporter/event-reporter-statefulset.yaml | 3 +-- 9 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Procfile b/Procfile index b3545698c000b..2bb26a086fb1d 100644 --- a/Procfile +++ b/Procfile @@ -1,7 +1,7 @@ controller: [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "FORCE_LOG_COLORS=1 ARGOCD_FAKE_IN_CLUSTER=true ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} ARGOCD_SSH_DATA_PATH=${ARGOCD_SSH_DATA_PATH:-/tmp/argocd-local/ssh} ARGOCD_BINARY_NAME=argocd-application-controller $COMMAND --loglevel debug --redis localhost:${ARGOCD_E2E_REDIS_PORT:-6379} --repo-server localhost:${ARGOCD_E2E_REPOSERVER_PORT:-8081} --otlp-address=${ARGOCD_OTLP_ADDRESS} --application-namespaces=${ARGOCD_APPLICATION_NAMESPACES:-''}" api-server: [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "FORCE_LOG_COLORS=1 ARGOCD_FAKE_IN_CLUSTER=true ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} ARGOCD_SSH_DATA_PATH=${ARGOCD_SSH_DATA_PATH:-/tmp/argocd-local/ssh} ARGOCD_BINARY_NAME=argocd-server $COMMAND --loglevel debug --redis localhost:${ARGOCD_E2E_REDIS_PORT:-6379} --disable-auth=${ARGOCD_E2E_DISABLE_AUTH:-'true'} --insecure --dex-server http://localhost:${ARGOCD_E2E_DEX_PORT:-5556} --repo-server localhost:${ARGOCD_E2E_REPOSERVER_PORT:-8081} --port ${ARGOCD_E2E_APISERVER_PORT:-8080} --otlp-address=${ARGOCD_OTLP_ADDRESS} --application-namespaces=${ARGOCD_APPLICATION_NAMESPACES:-''}" dex: sh -c "ARGOCD_BINARY_NAME=argocd-dex go run github.com/argoproj/argo-cd/v2/cmd gendexcfg -o `pwd`/dist/dex.yaml && (test -f dist/dex.yaml || { echo 'Failed to generate dex configuration'; exit 1; }) && docker run --rm -p ${ARGOCD_E2E_DEX_PORT:-5556}:${ARGOCD_E2E_DEX_PORT:-5556} -v `pwd`/dist/dex.yaml:/dex.yaml ghcr.io/dexidp/dex:$(grep "image: ghcr.io/dexidp/dex" manifests/base/dex/argocd-dex-server-deployment.yaml | cut -d':' -f3) dex serve /dex.yaml" -redis: bash -c "if [ \"$ARGOCD_REDIS_LOCAL\" = 'true' ]; then redis-server --save '' --appendonly no --port ${ARGOCD_E2E_REDIS_PORT:-6379}; else docker run --rm --name argocd-redis -i -p ${ARGOCD_E2E_REDIS_PORT:-6379}:${ARGOCD_E2E_REDIS_PORT:-6379} docker.io/library/redis:7.0.14-alpine --save '' --appendonly no --port ${ARGOCD_E2E_REDIS_PORT:-6379}; fi" +redis: bash -c "if [ \"$ARGOCD_REDIS_LOCAL\" = 'true' ]; then redis-server --save '' --appendonly no --port ${ARGOCD_E2E_REDIS_PORT:-6379}; else docker run --rm --name argocd-redis -i -p ${ARGOCD_E2E_REDIS_PORT:-6379}:${ARGOCD_E2E_REDIS_PORT:-6379} docker.io/library/redis:$(grep "image: redis" manifests/base/redis/argocd-redis-deployment.yaml | cut -d':' -f3) --save '' --appendonly no --port ${ARGOCD_E2E_REDIS_PORT:-6379}; fi" repo-server: [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "FORCE_LOG_COLORS=1 ARGOCD_FAKE_IN_CLUSTER=true ARGOCD_GNUPGHOME=${ARGOCD_GNUPGHOME:-/tmp/argocd-local/gpg/keys} ARGOCD_PLUGINSOCKFILEPATH=${ARGOCD_PLUGINSOCKFILEPATH:-./test/cmp} ARGOCD_GPG_DATA_PATH=${ARGOCD_GPG_DATA_PATH:-/tmp/argocd-local/gpg/source} ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} ARGOCD_SSH_DATA_PATH=${ARGOCD_SSH_DATA_PATH:-/tmp/argocd-local/ssh} ARGOCD_BINARY_NAME=argocd-repo-server ARGOCD_GPG_ENABLED=${ARGOCD_GPG_ENABLED:-false} $COMMAND --loglevel debug --port ${ARGOCD_E2E_REPOSERVER_PORT:-8081} --redis localhost:${ARGOCD_E2E_REDIS_PORT:-6379} --otlp-address=${ARGOCD_OTLP_ADDRESS}" cmp-server: [ "$ARGOCD_E2E_TEST" = 'true' ] && exit 0 || [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "FORCE_LOG_COLORS=1 ARGOCD_FAKE_IN_CLUSTER=true ARGOCD_BINARY_NAME=argocd-cmp-server ARGOCD_PLUGINSOCKFILEPATH=${ARGOCD_PLUGINSOCKFILEPATH:-./test/cmp} $COMMAND --config-dir-path ./test/cmp --loglevel debug --otlp-address=${ARGOCD_OTLP_ADDRESS}" ui: sh -c 'cd ui && ${ARGOCD_E2E_YARN_CMD:-yarn} start' diff --git a/cmd/event-reporter-server/commands/event_reporter_server.go b/cmd/event-reporter-server/commands/event_reporter_server.go index 8dab65d957ebc..700e6360351fc 100644 --- a/cmd/event-reporter-server/commands/event_reporter_server.go +++ b/cmd/event-reporter-server/commands/event_reporter_server.go @@ -31,8 +31,8 @@ import ( ) const ( - failureRetryCountEnv = "ARGOCD_K8S_RETRY_COUNT" - failureRetryPeriodMilliSecondsEnv = "ARGOCD_K8S_RETRY_DURATION_MILLISECONDS" + failureRetryCountEnv = "EVENT_REPORTER_K8S_RETRY_COUNT" + failureRetryPeriodMilliSecondsEnv = "EVENT_REPORTE_K8S_RETRY_DURATION_MILLISECONDS" ) var ( @@ -45,7 +45,7 @@ func init() { failureRetryPeriodMilliSeconds = env.ParseNumFromEnv(failureRetryPeriodMilliSecondsEnv, failureRetryPeriodMilliSeconds, 0, 1000) } -// NewCommand returns a new instance of an argocd command +// NewCommand returns a new instance of an event reporter command func NewCommand() *cobra.Command { var ( redisClient *redis.Client @@ -70,10 +70,9 @@ func NewCommand() *cobra.Command { shardingAlgorithm string ) var command = &cobra.Command{ - Use: cliName, - Short: "Run the Event Reporter server", - // TODO: [Event Reporter] change description - Long: "The API server is a gRPC/REST server which exposes the API consumed by the Web UI, CLI, and CI/CD systems. This command runs API server in the foreground. It can be configured by following options.", + Use: cliName, + Short: "Run the Event Reporter server", + Long: "The Event reporter is a server that listens to Kubernetes events and reports them to the Codefresh server.", DisableAutoGenTag: true, Run: func(c *cobra.Command, args []string) { ctx := c.Context() diff --git a/common/common.go b/common/common.go index ff733fbb94fcd..d438ed4ab551b 100644 --- a/common/common.go +++ b/common/common.go @@ -15,7 +15,7 @@ import ( // Default service addresses and URLS of Argo CD internal services const ( // DefaultRepoServerAddr is the gRPC address of the Argo CD repo server - DefaultRepoServerAddr = "argo-cd-repo-server:8081" + DefaultRepoServerAddr = "argocd-repo-server:8081" DefaultApplicationServerAddr = "argo-cd-server:80" // DefaultDexServerAddr is the HTTP address of the Dex OIDC server, which we run a reverse proxy against DefaultDexServerAddr = "argocd-dex-server:5556" diff --git a/controller/sync.go b/controller/sync.go index 7158033fd8f51..783183c17fc7c 100644 --- a/controller/sync.go +++ b/controller/sync.go @@ -524,7 +524,7 @@ func hasSharedResourceCondition(app *v1alpha1.Application) (bool, string) { } // delayBetweenSyncWaves is a gitops-engine SyncWaveHook which introduces an artificial delay -// between each sync wave. We introduce an artificial delay in order give other controller a +// between each sync wave. We introduce an artificial delay in order give other controllers a // _chance_ to react to the spec change that we just applied. This is important because without // this, Argo CD will likely assess resource health too quickly (against the stale object), causing // hooks to fire prematurely. See: https://github.com/argoproj/argo-cd/issues/4669. diff --git a/event_reporter/metrics/metrics.go b/event_reporter/metrics/metrics.go index 26ac76c4b53b0..08bdd855d3fde 100644 --- a/event_reporter/metrics/metrics.go +++ b/event_reporter/metrics/metrics.go @@ -92,8 +92,6 @@ var ( func NewMetricsServer(host string, port int) *MetricsServer { mux := http.NewServeMux() registry := prometheus.NewRegistry() - //registry.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{})) - //registry.MustRegister(collectors.NewGoCollector()) mux.Handle("/metrics", promhttp.HandlerFor(prometheus.Gatherers{ registry, diff --git a/event_reporter/server.go b/event_reporter/server.go index 686a561546b6c..9f76a3b7e4920 100644 --- a/event_reporter/server.go +++ b/event_reporter/server.go @@ -66,7 +66,7 @@ type EventReporterServer struct { appLister applisters.ApplicationLister db db.ArgoDB - // stopCh is the channel which when closed, will shutdown the Argo CD server + // stopCh is the channel which when closed, will shutdown the Event Reporter server stopCh chan struct{} serviceSet *EventReporterServerSet featureManager *reporter.FeatureManager @@ -237,7 +237,7 @@ func (a *EventReporterServer) Run(ctx context.Context, lns *Listeners) { <-a.stopCh } -// NewServer returns a new instance of the Argo CD API server +// NewServer returns a new instance of the Event Reporter server func NewEventReporterServer(ctx context.Context, opts EventReporterServerOpts) *EventReporterServer { settingsMgr := settings_util.NewSettingsManager(ctx, opts.KubeClientset, opts.Namespace) settings, err := settingsMgr.InitializeSettings(true) diff --git a/event_reporter/sharding/sharding.go b/event_reporter/sharding/sharding.go index 309e6e91d4e26..0149cb71694ab 100644 --- a/event_reporter/sharding/sharding.go +++ b/event_reporter/sharding/sharding.go @@ -57,7 +57,6 @@ func (s *sharding) LegacyDistributionFunction() DistributionFunction { return 0 } id := a.Name - log.Debugf("Calculating application shard for cluster id: %s", id) if id == "" { return 0 } else { diff --git a/manifests/base/event-reporter/event-reporter-service.yaml b/manifests/base/event-reporter/event-reporter-service.yaml index 0ba459fcd2a49..6a89a2f9d17db 100644 --- a/manifests/base/event-reporter/event-reporter-service.yaml +++ b/manifests/base/event-reporter/event-reporter-service.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: labels: - app.kubernetes.io/name: argocd-server + app.kubernetes.io/name: event-reporter app.kubernetes.io/part-of: argocd app.kubernetes.io/component: event-reporter name: event-reporter diff --git a/manifests/base/event-reporter/event-reporter-statefulset.yaml b/manifests/base/event-reporter/event-reporter-statefulset.yaml index 6844d6bf08fb4..92d336b0681ce 100644 --- a/manifests/base/event-reporter/event-reporter-statefulset.yaml +++ b/manifests/base/event-reporter/event-reporter-statefulset.yaml @@ -20,7 +20,7 @@ spec: serviceAccountName: event-reporter containers: - name: event-reporter - image: docker.io/xeonalex/personal-argocd-dev:reporting-v2-test-v20 + image: quay.io/argoproj/argocd:latest imagePullPolicy: Always args: - /usr/local/bin/event-reporter-server @@ -43,7 +43,6 @@ spec: secretKeyRef: key: token name: codefresh-token - # todo: clean up - name: EVENT_REPORTER_INSECURE valueFrom: configMapKeyRef: