argoproj / notifications-engine

Affordable notifications for Kubernetes
Apache License 2.0
271 stars 147 forks source link

Bug: `github` service only sends last template when triggered #229

Open bradgwest opened 11 months ago

bradgwest commented 11 months ago

Summary

Only the last template specified in a trigger will be sent when using the github service. I'm not sure if this behavior extends to other services.

Observed Behavior

Consider the following config. Note that two templates are specified in the "send" clause of the on-deployed trigger.

  trigger.on-deployed: |
      - description: Application successfully deployed
        send: [app-deployed, app-config-deployed]
        when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'

  template.app-deployed: |
      message: |
        Successfully deployed `{{.app.metadata.name}}`.
      github:
        repoURLPath: '{{((first .app.status.sync.comparedTo.sources).repoURL)}}'
        revisionPath: "{{(first .app.status.sync.revisions)}}"
        status:
          state: success
          label: "continuous-delivery/{{.app.metadata.labels.environment}}/{{.app.metadata.name}}"
          targetURL: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"

  template.app-config-deployed: |
      message: |
        Successfully deployed `{{.app.metadata.name}}` with this config.
      github:
        repoURLPath: "git:github.com:org/config.git"
        revisionPath: "{{(last (last .app.status.history).revisions)}}"
        status:
          state: success
          label: "continuous-delivery/{{.app.metadata.labels.environment}}/{{.app.metadata.name}}"
          targetURL: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"

Only the app-config-deployed notification will be sent. The service quietly fails to send app-deployed. Not even a debug log is emitted.

Expected Behavior

  1. I expect an error log when a notification fails to send.
  2. I expect every templates/notifications specified in the send configuration of the trigger to be sent.
  3. I expect any deviation from this behavior to be documented.

Version

notifications-engine@v0.4.1-0.20230620204159-3446d4ae8520

Logs

info: Trigger on-deployed result: [{[0].y7b5sbwa2Q329JYH755peeq-fBs  [app-deployed app-config-deployed] true}]
info: Sending notification about condition 'on-deployed.[0].y7b5sbwa2Q329JYH755peeq-fBs' to '{github }'
debug: Sending request: POST /app/installations/redacted/access_tokens <redacted>
debug: msg="Received response: HTTP/2.0 201 Created <redacted>
debug: msg="Sending request: POST /repos/org/config/statuses/17b9362483179c29dfb79a5aa4bc7b41e01a229f <redacted>
debug: msg="Received response: HTTP/2.0 201 Created\r <redacted>
debug: Notification  was sent