Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argo Notifications operationState.phase unexpected behavior #21968

Open
3 tasks done
Hapshanko opened this issue Feb 24, 2025 · 0 comments
Open
3 tasks done

Argo Notifications operationState.phase unexpected behavior #21968

Hapshanko opened this issue Feb 24, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Hapshanko
Copy link
Contributor

Hapshanko commented Feb 24, 2025

Checklist:

  • I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • I've included steps to reproduce the bug.
  • I've pasted the output of argocd version.

Describe the bug

Hey, some unexpected behavior I encountered regarding the notification behavior:

  1. The documentation example of using
    when: app.status.operationState.phase in ['Succeeded']
    results in the errors attached in the screenshot (first lines) while the application is new and was just deployed without being synced (so guessing it has no operationState.phase). is this intended? am I supposed to add an != 'null'? if so, id be glad for a clarificiation and ill add it to the documentation as well, just expected it to integrate better with ArgoCD itself and avoid these errors since it is even part of the same repo.

  2. Regarding the 2 DEBUG logs at bottom of the logs I sent, I configured a service, trigger, and template for a webhook to my custom internal k8s service, I configured it to be only POST (in the template) but for some reason it sends a GET request before the POST so there are actually 2 requests. is this intended? here is my configuration if this is needed:

To trigger the notification all im doing is deploying a basic Argo app (using argoproj's guestbook example in argocd-example-apps).
Note the != null I added is due to the aforementioned missing phase issue.

    service.webhook.notify-success-test-api: |
      url: http://http-echo.default.svc.cluster.local
      headers:
      - name: "Content-Type"
        value: "application/json"
      insecureSkipVerify: true
    service.webhook.notify-fail-test-api: |
      url: http://http-echo.default.svc.cluster.local
      headers:
      - name: "Content-Type"
        value: "application/json"
      insecureSkipVerify: true
    trigger.on-first-deployed-app: |
      - when: app.status.operationState != null and app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy' and app.status.sync.status == 'Synced'
        oncePer: app.metadata.name
        send: [notify-success-test-api]
        description: A new app is synced and healthy.
      - when: app.status.operationState != null and app.status.operationState.phase in ['Error', 'Failed'] or app.status.health.status != 'Healthy'
        oncePer: app.metadata.name
        send: [notify-fail-test-api]
        description: A new app is failing.
    template.notify-success-test-api: |
      webhook:
        notify-success-test-api:
          method: POST
          path: /test
          body: |
            {
              "argocd_app_name": "{{`{{.app.metadata.name}}`}}",
              "state": "success"
            }
    template.notify-fail-test-api: |
      webhook:
        notify-fail-test-api:
          method: POST
          path: /test
          body: |
            {
              "argocd_app_name": "{{`{{.app.metadata.name}}`}}",
              "state": "error"
            }

Thanks in advance!

To Reproduce

See configuration above.

Expected behavior

No errors for a missing phase on a new app + only a POST request instead of a GET+POST.

Screenshots

Image

Version

v2.10.6+d504d2b

Logs

time="2025-02-20T11:20:52Z" level=error msg="failed to execute when condition: cannot fetch phase from <nil> (1:27)\n | app.status.operationState.phase in ['Succeeded']"
time="2025-02-20T11:21:32Z" level=error msg="failed to execute when condition: cannot fetch phase from <nil> (1:27)\n | app.status.operationState.phase in ['Succeeded']"
time="2025-02-20T11:22:28Z" level=error msg="failed to execute when condition: cannot fetch phase from <nil> (1:27)\n | app.status.operationState.phase in ['Succeeded']"
2025/02/20 11:22:31 [DEBUG] GET http://http-echo.default.svc.cluster.local
2025/02/20 11:22:31 [DEBUG] POST http://http-echo.default.svc.cluster.local/test
@Hapshanko Hapshanko added the bug Something isn't working label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant