notifications-engine: oncePer condition logs expected error
In argocd notifications, I use the following trigger to filter notifications with the oncePer option.
trigger.on-deployed: |
- description: Application is synced and healthy. Triggered once per commit.
when: app.status.health.status == 'Healthy' and app.status.operationState != nil and app.status.operationState.phase in ['Succeeded']
oncePer: app.status.operationState.syncResult.revision
send:
- app-deployed
This returns the following error in the logs
{"level":"error","msg":"failed to execute oncePer condition: cannot fetch syncResult from \u003cnil\u003e (1:27)\n | app.status.operationState.syncResult.revision\n | ..........................^","time":"2022-01-28T15:41:46Z"}
Solution
I think the oncePer condition should not be evaluated when the when condition evaluate to false.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 19
- Comments: 16
I suggest using the following condition:
This also directly supports multi source apps.
Im experiencing something similar:
We are using a monorepo for multiple applications and environments.
oncePer: app.status.operationState.syncResult.revision and app.metadata.name-> This prevents each application from spamming logs everytime any env or app changes. Its working, but the notification service is spamming logs:Hitting the same issue. Here is our
on-sync-failedtrigger definition (copied from the official Triggers and Templates catalog):The notification controller send those logs:
Version: v2.7.2
Hitting the same issue
version:
v2.6.4+7be094f@woehrl01 how can you added another var to evaluate? Trying to add
app.status.operationState.finishedAtlike sooncePer: "[app.status?.sync?.revision, app.status?.sync?.revisions, app.status.operationState.finishedAt]"oroncePer: "[app.status?.sync?.revision, app.status?.sync?.revisions]" and app.status.operationState.finishedAtneither work
Same error with defaults triggers from catalog: Version: 2.7.2
notifications-controller logs:
cannot fetch phase from <nil> (1:27)\n | app.status.operationState.phase in ['Succeeded']\n | ..........................^"