Skip to content

Commit

Permalink
Add error condition when notification replica is greater than 1 (#1642)
Browse files Browse the repository at this point in the history
* Add error condition when notification replica is greater than 1

Signed-off-by: Rizwana777 <[email protected]>

* display the warning instead of returning an error

Signed-off-by: Rizwana777 <[email protected]>

* Remove getArgoCDNotificationsControllerReplicas func as it we are ignoring replica values

Signed-off-by: Rizwana777 <[email protected]>

---------

Signed-off-by: Rizwana777 <[email protected]>
  • Loading branch information
Rizwana777 authored Feb 5, 2025
1 parent 8210187 commit 26e431c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
5 changes: 5 additions & 0 deletions controllers/argocd/argocd_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ 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, display a warning.
if argocd.Spec.Notifications.Replicas != nil && *argocd.Spec.Notifications.Replicas > 1 {
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)
labelSelector, err := labels.Parse(r.LabelSelector)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions controllers/argocd/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 0 additions & 13 deletions controllers/argocd/notifications_util.go
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
}

0 comments on commit 26e431c

Please sign in to comment.