argoproj / argo-cd

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

argocd-notifications-controller on-delete trigger result is always empty and doesn't send notification #18203

Open akennealy opened 2 weeks ago

akennealy commented 2 weeks ago

Checklist:

Describe the bug

The argocd-notifications-controller controller on-delete trigger logs an empty result and never triggers the webhook templated. However, I can see a successful true result if manually triggered via argcd cli.

To Reproduce

1) Create/apply the on-delete trigger and template (I'm using webhook). Refer to notifications_catalog examples.

Trigger: ```yaml - when: app.metadata.deletionTimestamp != nil description: Application is deleted. send: [app-deleted] oncePer: app.metadata.name ``` My configuration Template: ```yaml template.app-deleted: | webhook: mywebhook: method: POST path: /argo-hooks body: | { "description": "Application is deleted.", "klipenvId": "{{.app.metadata.name}}", "event": "app_deleted", "url": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", "context": "continuous-delivery/{{.app.metadata.name}}" ```

2) Create/apply an Application that subscribes to the on-delete trigger 3) Use argocd cli to manually verify that the trigger returns false, as expected:

argocd admin notifications trigger run on-deleted <app-name>

CONDITION                                RESULT
app.metadata.deletionTimestamp != nil    false

4) Delete the app (add the metadata.deletionTimestamp field) 5) Use argocd cli to again manually run the trigger and see the result is now true

argocd admin notifications trigger run on-deleted <app-name>
CONDITION                                RESULT
app.metadata.deletionTimestamp != nil    true

6) Bug: Tail the argocd-notifications-controller logs, you'll see the on-delete trigger always has an empty result:

msg="Trigger on-delete result: []" resource=argocd/myapp
msg="Trigger on-delete result: []" resource=argocd/myapp
...

Expected behavior The on-delete trigger should fire with a successful result and trigger the webhook template. Also, the info level logs should show the results of the app.metadata.deletionTimestamp != nil

Version

  argocd: v2.10.5+335875d.dirty
  BuildDate: 2024-03-28T18:33:38Z
  GitCommit: 335875d13e018bed6e03873f4742582582964745
  GitTreeState: dirty
  GoVersion: go1.22.1
  Compiler: gc
  Platform: darwin/arm64