argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.58k stars 5.35k forks source link

notification - trigger is not configured using the configuration in namespace #17773

Open andronux opened 5 months ago

andronux commented 5 months ago

Hello everyone,

version: argocd:v2.10.6

I keep getting the following error:

argocd-notifications-controller-65664f4d96-zvxgm notifications-controller time="2024-04-08T08:56:18Z" level=debug msg="Failed to execute condition of trigger on-health-degraded: trigger 'on-health-degraded' is not configured using the configuration in namespace argocd" resource=argocd/kube-prometheus-stack

Although I have my service/triggers/templates configured in the configmap argocd-notifications-cm.

Am I missing something here? Thanks

andronux commented 5 months ago

Any help from anyone please?

andronux commented 5 months ago

@jannfis any chance you could help me with this?

ericjmooney commented 4 months ago

@andronux -- not sure if you have made any progress but i ran into this same issue today. after a lot of screwing around and trial and error, i have come to believe that it is now necessary to have a trigger defined for this thing to work.

this example file was very helpful for me to try to figure out how this should work https://github.com/argoproj-labs/argocd-notifications/blob/master/docs/argocd-notifications-cm.yaml

Ultimately I ended up w/ a configmap like this (just the data section for relevance):

apiVersion: v1
data:
  context: |
    argocdUrl: https://my-argocd.ericexample.com

  service.email.smtp: |
    host: mail.ericexample.com
    port: 587
    from: argocd@ericexample.com

  template.eric-app-sync-running: |
    message: |
      The sync operation of application {{.app.metadata.name}} has started at {{.app.status.operationState.startedAt}}.
      Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true
    email:
      subject: Start syncing application {{.app.metadata.name}}.

  trigger.app-sync-running: |
    - when: true
      send: [eric-app-sync-running]

and the annotation on my application like: notifications.argoproj.io/subscribe.app-sync-running.smtp=eric@ericexample.com

Hope this helps!

ddeath commented 1 month ago

@ericjmooney did you get same error message? trigger is not configured using the configuration in namespace

Also in which namespace is your app running?

To me this looks like having trigger and template definitions in argocd namespace is not enough.

I see same error on 2.12.0

ddeath commented 1 month ago

@andronux so I tested it out and if I create new configmap with triggers and templates in namespace where application is running, then the error message is gone.... In the debug logs I can see that it is trying to send slack message now, however failing because invalid auth... I think it will need also secrets in that namespace....

Just for reference this is the configmap I created manually:

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
  namespace: app-services
  labels:
    helm.sh/chart: argo-cd-7.4.1
    app.kubernetes.io/name: argocd-notifications-controller
    app.kubernetes.io/instance: argo
    app.kubernetes.io/component: notifications-controller
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/part-of: argocd
    app.kubernetes.io/version: "v2.12.0"
data:
  context: |
    argocdUrl: https://localhost:8080
  service.slack: |
    token: $slack-token
  template.microservice-sync-failed: |
    message: |
      {{if eq .serviceType "slack"}}:exclamation:{{end}}  The sync operation of ** {{.app.metadata.name}} ** has failed at {{.app.status.operationState.finishedAt}} with the following error: {{.app.status.operationState.message}}
      Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true .

      {{((call .repo.GetAppDetails).Helm.GetParameterValueByName "boundedContext") }}
    slack:
      attachments: |-
        [{
          "title": "{{ .app.metadata.name}}",
          "title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
          "color": "#E96D76",
          "fields": [
          {
            "title": "Sync Status",
            "value": "{{.app.status.sync.status}}",
            "short": true
          },
          {
            "title": "Repository",
            "value": "{{.app.spec.source.repoURL}}",
            "short": true
          }
          {{range $index, $c := .app.status.conditions}}
          {{if not $index}},{{end}}
          {{if $index}},{{end}}
          {
            "title": "{{$c.type}}",
            "value": "{{$c.message}}",
            "short": true
          }
          {{end}}
          ]
        }]
  trigger.microservice-sync-failed: |
    - description: Service syncing has failed
      send: [microservice-sync-failed]
      when: app.status.operationState != nil and app.status.operationState.phase in ['Error', 'Failed']
ddeath commented 1 month ago

Just small realization, it is not actually error message I guess. What is happening is that it will try to look for configuration with namespace where app is running and if it does not find, it will print that message. After that it will look into argocd namespace for those triggers and templates

roshnij7 commented 1 week ago

Application is running in different namespace in different cluster, how to configure it