From 4e9d634929171cf2e52a9b162403244e38d55243 Mon Sep 17 00:00:00 2001 From: Rizwana777 Date: Tue, 21 Jan 2025 17:03:25 +0530 Subject: [PATCH 1/3] Add error condition when notification replica is greater than 1 Signed-off-by: Rizwana777 --- controllers/argocd/argocd_controller.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/controllers/argocd/argocd_controller.go b/controllers/argocd/argocd_controller.go index efb4974d6..da401d410 100644 --- a/controllers/argocd/argocd_controller.go +++ b/controllers/argocd/argocd_controller.go @@ -130,6 +130,13 @@ func (r *ReconcileArgoCD) internalReconcile(ctx context.Context, request ctrl.Re return reconcile.Result{}, argocd, err } + // If the number of notification replicas is greater than 1, return an error + if argocd.Spec.Notifications.Replicas != nil && *argocd.Spec.Notifications.Replicas > 1 { + message := "Argo CD Notification controller does not support multiple replicas. Notification replicas cannot be greater than 1." + reqLogger.Info(message) + return reconcile.Result{}, argocd, fmt.Errorf("%s", message) + } + // Fetch labelSelector from r.LabelSelector (command-line option) labelSelector, err := labels.Parse(r.LabelSelector) if err != nil { From 225aacc6a505bc65a65a7c588d4f987345c5d86d Mon Sep 17 00:00:00 2001 From: Rizwana777 Date: Fri, 24 Jan 2025 15:45:47 +0530 Subject: [PATCH 2/3] display the warning instead of returning an error Signed-off-by: Rizwana777 --- controllers/argocd/argocd_controller.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/controllers/argocd/argocd_controller.go b/controllers/argocd/argocd_controller.go index da401d410..1243d38b0 100644 --- a/controllers/argocd/argocd_controller.go +++ b/controllers/argocd/argocd_controller.go @@ -130,11 +130,9 @@ func (r *ReconcileArgoCD) internalReconcile(ctx context.Context, request ctrl.Re return reconcile.Result{}, argocd, err } - // If the number of notification replicas is greater than 1, return an error + // If the number of notification replicas is greater than 1, display a warning. if argocd.Spec.Notifications.Replicas != nil && *argocd.Spec.Notifications.Replicas > 1 { - message := "Argo CD Notification controller does not support multiple replicas. Notification replicas cannot be greater than 1." - reqLogger.Info(message) - return reconcile.Result{}, argocd, fmt.Errorf("%s", message) + reqLogger.Info("WARNING: Argo CD Notification controller does not support multiple replicas. Notification replicas cannot be greater than 1.") } // Fetch labelSelector from r.LabelSelector (command-line option) From b55c763787b2fc858711ea190a68f443bcf64597 Mon Sep 17 00:00:00 2001 From: Rizwana777 Date: Tue, 4 Feb 2025 10:45:40 +0530 Subject: [PATCH 3/3] Remove getArgoCDNotificationsControllerReplicas func as it we are ignoring replica values Signed-off-by: Rizwana777 --- controllers/argocd/notifications.go | 4 ---- controllers/argocd/notifications_util.go | 13 ------------- 2 files changed, 17 deletions(-) diff --git a/controllers/argocd/notifications.go b/controllers/argocd/notifications.go index 2150e63dd..f65e4d716 100644 --- a/controllers/argocd/notifications.go +++ b/controllers/argocd/notifications.go @@ -338,10 +338,6 @@ func (r *ReconcileArgoCD) reconcileNotificationsDeployment(cr *argoproj.ArgoCD, Type: appsv1.RecreateDeploymentStrategyType, } - if replicas := getArgoCDNotificationsControllerReplicas(cr); replicas != nil { - desiredDeployment.Spec.Replicas = replicas - } - notificationEnv := cr.Spec.Notifications.Env // Let user specify their own environment first notificationEnv = argoutil.EnvMerge(notificationEnv, proxyEnvVars(), false) diff --git a/controllers/argocd/notifications_util.go b/controllers/argocd/notifications_util.go index ab8dec9e8..814e93a66 100644 --- a/controllers/argocd/notifications_util.go +++ b/controllers/argocd/notifications_util.go @@ -1,7 +1,5 @@ package argocd -import argoproj "github.com/argoproj-labs/argocd-operator/api/v1beta1" - // getDefaultNotificationsContext returns an empty map for context func getDefaultNotificationsContext() map[string]string { notificationContext := make(map[string]string) @@ -557,14 +555,3 @@ func getDefaultNotificationsTriggers() map[string]string { return notificationsTriggers } - -// getArgoCDNotificationsControllerReplicas will return the size value for the argocd-notifications-controller replica count if it -// has been set in argocd CR. Otherwise, nil is returned if the replicas is not set in the argocd CR or -// replicas value is < 0. -func getArgoCDNotificationsControllerReplicas(cr *argoproj.ArgoCD) *int32 { - if cr.Spec.Notifications.Replicas != nil && *cr.Spec.Notifications.Replicas >= 0 { - return cr.Spec.Notifications.Replicas - } - - return nil -}