mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 08:57:17 +00:00
feat: expose notifications controller processors count via cmd params (#26798)
Signed-off-by: Kirill Bilchenko <kirillbilchenko@users.noreply.github.com>
This commit is contained in:
parent
f8c0d7efcf
commit
3cb4955d44
13 changed files with 100 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ package commands
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
|
@ -162,7 +163,7 @@ func NewCommand() *cobra.Command {
|
|||
},
|
||||
}
|
||||
clientConfig = cli.AddKubectlFlagsToCmd(&command)
|
||||
command.Flags().IntVar(&processorsCount, "processors-count", 1, "Processors count.")
|
||||
command.Flags().IntVar(&processorsCount, "processors-count", env.ParseNumFromEnv("ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT", 1, 1, math.MaxInt32), "Processors count.")
|
||||
command.Flags().StringVar(&appLabelSelector, "app-label-selector", "", "App label selector.")
|
||||
command.Flags().StringVar(&logLevel, "loglevel", env.StringFromEnv("ARGOCD_NOTIFICATIONS_CONTROLLER_LOGLEVEL", "info"), "Set the logging level. One of: debug|info|warn|error")
|
||||
command.Flags().StringVar(&logFormat, "logformat", env.StringFromEnv("ARGOCD_NOTIFICATIONS_CONTROLLER_LOGFORMAT", "json"), "Set the logging format. One of: json|text")
|
||||
|
|
|
|||
28
cmd/argocd-notification/commands/argocd_notification_test.go
Normal file
28
cmd/argocd-notification/commands/argocd_notification_test.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNewCommandProcessorsCountDefault(t *testing.T) {
|
||||
t.Setenv("ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT", "4")
|
||||
|
||||
cmd := NewCommand()
|
||||
|
||||
processorsCount, err := cmd.Flags().GetInt("processors-count")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 4, processorsCount)
|
||||
}
|
||||
|
||||
func TestNewCommandProcessorsCountInvalidEnvFallsBackToDefault(t *testing.T) {
|
||||
t.Setenv("ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT", "0")
|
||||
|
||||
cmd := NewCommand()
|
||||
|
||||
processorsCount, err := cmd.Flags().GetInt("processors-count")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 1, processorsCount)
|
||||
}
|
||||
|
|
@ -393,6 +393,8 @@ data:
|
|||
notificationscontroller.log.level: "info"
|
||||
# Set the logging format. One of: json|text (default "json")
|
||||
notificationscontroller.log.format: "json"
|
||||
# Number of notification processors (default 1)
|
||||
notificationscontroller.processors.count: "1"
|
||||
# Enable self-service notifications config. Used in conjunction with apps-in-any-namespace. (default "false")
|
||||
notificationscontroller.selfservice.enabled: "false"
|
||||
# Disable TLS on connections to repo server
|
||||
|
|
|
|||
|
|
@ -70,6 +70,19 @@ data:
|
|||
notificationscontroller.selfservice.enabled: "true"
|
||||
```
|
||||
|
||||
Other notifications controller startup settings can be managed the same way. For notifications-heavy
|
||||
installations, `notificationscontroller.processors.count` configures the worker concurrency and maps
|
||||
to the `--processors-count` startup flag. For example:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: argocd-cmd-params-cm
|
||||
data:
|
||||
notificationscontroller.processors.count: "4"
|
||||
```
|
||||
|
||||
To use this feature, you can deploy configmap named `argocd-notifications-cm` and possibly a secret `argocd-notifications-secret` in the namespace where the Argo CD application lives.
|
||||
|
||||
When it is configured this way the controller will send notifications using both the controller level configuration (the configmap located in the same namespaces as the controller) as well as
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@ spec:
|
|||
key: notificationscontroller.log.level
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
key: notificationscontroller.processors.count
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_LOG_FORMAT_TIMESTAMP
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
|
|
@ -96,4 +102,4 @@ spec:
|
|||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
kubernetes.io/os: linux
|
||||
|
|
|
|||
6
manifests/ha/install-with-hydrator.yaml
generated
6
manifests/ha/install-with-hydrator.yaml
generated
|
|
@ -33129,6 +33129,12 @@ spec:
|
|||
key: notificationscontroller.log.level
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
key: notificationscontroller.processors.count
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_LOG_FORMAT_TIMESTAMP
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
|
|
|
|||
6
manifests/ha/install.yaml
generated
6
manifests/ha/install.yaml
generated
|
|
@ -32959,6 +32959,12 @@ spec:
|
|||
key: notificationscontroller.log.level
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
key: notificationscontroller.processors.count
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_LOG_FORMAT_TIMESTAMP
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
|
|
|
|||
|
|
@ -2376,6 +2376,12 @@ spec:
|
|||
key: notificationscontroller.log.level
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
key: notificationscontroller.processors.count
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_LOG_FORMAT_TIMESTAMP
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
|
|
|
|||
6
manifests/ha/namespace-install.yaml
generated
6
manifests/ha/namespace-install.yaml
generated
|
|
@ -2206,6 +2206,12 @@ spec:
|
|||
key: notificationscontroller.log.level
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
key: notificationscontroller.processors.count
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_LOG_FORMAT_TIMESTAMP
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
|
|
|
|||
6
manifests/install-with-hydrator.yaml
generated
6
manifests/install-with-hydrator.yaml
generated
|
|
@ -32147,6 +32147,12 @@ spec:
|
|||
key: notificationscontroller.log.level
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
key: notificationscontroller.processors.count
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_LOG_FORMAT_TIMESTAMP
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
|
|
|
|||
6
manifests/install.yaml
generated
6
manifests/install.yaml
generated
|
|
@ -31975,6 +31975,12 @@ spec:
|
|||
key: notificationscontroller.log.level
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
key: notificationscontroller.processors.count
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_LOG_FORMAT_TIMESTAMP
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
|
|
|
|||
6
manifests/namespace-install-with-hydrator.yaml
generated
6
manifests/namespace-install-with-hydrator.yaml
generated
|
|
@ -1394,6 +1394,12 @@ spec:
|
|||
key: notificationscontroller.log.level
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
key: notificationscontroller.processors.count
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_LOG_FORMAT_TIMESTAMP
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
|
|
|
|||
6
manifests/namespace-install.yaml
generated
6
manifests/namespace-install.yaml
generated
|
|
@ -1222,6 +1222,12 @@ spec:
|
|||
key: notificationscontroller.log.level
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_NOTIFICATION_CONTROLLER_PROCESSORS_COUNT
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
key: notificationscontroller.processors.count
|
||||
name: argocd-cmd-params-cm
|
||||
optional: true
|
||||
- name: ARGOCD_LOG_FORMAT_TIMESTAMP
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
|
|
|
|||
Loading…
Reference in a new issue