Add support for github service notifications with multi source apps
As described in this issue, it looks like the github notification service has not implemented the support for multi source applications and it's returning an out of range error as it's only considering the repoURL inside single source definition (that is "" when using multi source)
error:
Index out of range [1] with length 1\ngoroutine 189 [running]:\nruntime/debug.Stack()\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x65\ngithub.com/argoproj/notifications-engine/pkg/controller.(*notificationController).processQueueItem.func1()\n\t/go/pkg/mod/github.com/argoproj/[email protected]/pkg/controller/controller.go:258 +0x65\npanic({0x3788a00, 0xc000c6cc48})\n\t/usr/local/go/src/runtime/panic.go:890 +0x263\ngithub.com/argoproj/notifications-engine/pkg/services.gitHubService.Send({{{0x3211380, 0xc0019cbdf8}, {0x3211380, 0xc0019cbe08}, {0xc00075e000, 0x68f}, {0x0, 0x0}}, 0xc0004ce600}, {{0xc00037f3a0, ...}, ...}, ...)\n\t/go/pkg/mod/github.com/argoproj/[email protected]/pkg/services/github.go:280 +0x6c9\ngithub.com/argoproj/notifications-engine/pkg/api.
It looks like it's working with a fixed repoUrl template
In our case, we are using three different sources with 2 repositories:
- One using a helm chart from first repository
- Another one using a ref to another repository to pick chart value files
- A third one to apply manifests
Something like:
sources:
- repoURL: 'https://artifactory/chart'
chart: chart-name
targetRevision: 'branch'
helm:
valueFiles:
- $values/folder/values.yaml
- $values/folder/values2.yaml
- repoURL: 'repo2'
targetRevision: 'branch'
ref: values
- repoURL: 'repo2'
targetRevision: 'branch'
path: 'manifests-path'
So our app revisions looks like
[
"2.2.3",
"b9cc369644fe34f7a85942266ae0b1fcb26b1de1",
"b9cc369644fe34f7a85942266ae0b1fcb26b1de1"
]
I've been playing a bit with the code and managed to extract the repository from multi source by modifying the template but the main problem I found is... to which repository do you send the github update with a setup like this without extending the application spec to be able to configure the target notification repository? (or similar)
Is there any plan to adapt this service to be able to inspect multi source repo urls and revisions?
Thanks in advance
Is this still an issue?
It is ! I think a workaround would be to set a custom repoURLPath on your templates:
github:
repoURLPath: "{{.app.metadata.annotations.argocdRepoURL}}"
And then set this annotation on all Application annotations / ApplicationSet templates annotations:
annotations:
# repo to which push notifications
argocdRepoURL: "https://github.com/my-org/my-explicit-repo"
#
notifications.argoproj.io/subscribe.on-sync-running.github: ""
notifications.argoproj.io/subscribe.on-sync-failed.github: ""
notifications.argoproj.io/subscribe.on-sync-succeeded.github: ""
notifications.argoproj.io/subscribe.on-sync-status-unknown.github: ""
notifications.argoproj.io/subscribe.on-deployed.github: ""
I havent been able to use something like github.notifications.argoproj.io/repo-url instead of argocdRepoURL tho, I think there is something about html/template that prevents me from reading annotations fields with slashes and dots
On a second though revisionPath, which is {{.app.status.operationState.syncResult.revision}} by default, is trickier to bypass...
{{.app.status.operationState.syncResult.revisions[0]}} with whatever index is the argocdRepoURL in sources should be used in case of multi-sources, but will not be available for single source Application.
A complex template which would coalesce multiple fields would also be a good workaround, but I have no clue on how to proceed here !
I'd join @CarlosLanderas on the necessity to add something like leaderSource in Application spec in case of sources usage; it would be an index, and not specifying it would use the first source as notified repo.
I've gotten it to work with an annotation of the source index you want to create the github check from. Confirmed what @Amphaal found with needing to use annotation names without slashes or dots.
github:
repoURLPath: "{{(index .app.spec.sources (default 0 (int .app.metadata.annotations.argoNotificationsGithubSourceIndex))).repoURL}}"
revisionPath: "{{(index .app.status.operationState.syncResult.revisions (default 0 (int .app.metadata.annotations.argoNotificationsGithubSourceIndex)))}}"