Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Slack notifications not working in argo #406

Open
rahul799 opened this issue Jun 6, 2022 · 6 comments
Open

Slack notifications not working in argo #406

rahul799 opened this issue Jun 6, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@rahul799
Copy link

rahul799 commented Jun 6, 2022

Summary

I followed all the steps mentioned here with an on-sync subscription method. But whenever sync is going on I can see below logs
level=info msg="Trigger on-sync-running result: []" app=argocd/grafana
in argocd-notifications-controlle pod.
There are no notifications on slack.

I am using KOPS to manage my cluster.

I am using latest versions of argocd and notification controller

time="2022-06-06T11:51:52Z" level=info msg="Start processing" app=argocd/kafka-exporter
time="2022-06-06T11:51:52Z" level=info msg="Processing completed" app=argocd/kafka-exporter
time="2022-06-06T11:51:52Z" level=info msg="Start processing" app=argocd/website
time="2022-06-06T11:51:52Z" level=info msg="Processing completed" app=argocd/website
time="2022-06-06T11:51:52Z" level=info msg="Start processing" app=argocd/rumbl-admin
time="2022-06-06T11:51:52Z" level=info msg="Processing completed" app=argocd/rumbl-admin
time="2022-06-06T11:51:52Z" level=info msg="Start processing" app=argocd/metric-server
time="2022-06-06T11:51:52Z" level=info msg="Processing completed" app=argocd/metric-server
time="2022-06-06T11:51:52Z" level=info msg="Start processing" app=argocd/kubernetes-node-exporter
time="2022-06-06T11:51:52Z" level=info msg="Processing completed" app=argocd/kubernetes-node-exporter
time="2022-06-06T11:51:52Z" level=info msg="Start processing" app=argocd/dhaniya-server
time="2022-06-06T11:51:52Z" level=info msg="Processing completed" app=argocd/dhaniya-server
time="2022-06-06T11:51:52Z" level=info msg="Start processing" app=argocd/kube-state-metrics
time="2022-06-06T11:51:52Z" level=info msg="Processing completed" app=argocd/kube-state-metrics
time="2022-06-06T11:51:52Z" level=info msg="Start processing" app=argocd/rumbl-js
time="2022-06-06T11:51:52Z" level=info msg="Processing completed" app=argocd/rumbl-js
time="2022-06-06T11:51:52Z" level=info msg="Start processing" app=argocd/prometheus
time="2022-06-06T11:51:52Z" level=info msg="Processing completed" app=argocd/prometheus
time="2022-06-06T11:51:52Z" level=info msg="Start processing" app=argocd/grafana
time="2022-06-06T11:51:52Z" level=info msg="Trigger on-sync-succeeded result: []" app=argocd/grafana
time="2022-06-06T11:51:52Z" level=info msg="Trigger on-sync-running result: []" app=argocd/grafana
time="2022-06-06T11:51:52Z" level=info msg="Processing completed" app=argocd/grafana
time="2022-06-06T11:52:23Z" level=info msg="Settings had been updated. Restarting controller..."

Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.

@rahul799 rahul799 added the bug Something isn't working label Jun 6, 2022
@Geethree
Copy link

Geethree commented Jun 7, 2022

This has been hitting me as well. I've also noticed that the troubleshooting for the argocd-notification controller deployed as a part of argocd doesn't work.

It appears as if the subcommands aren't there as it tries to start argocd-notifications... help only shows flags

gerald@gerald-laptop:~/playground/spinnaker-cloud-api-pipelines$ kubectl -n argocd exec -it argocd-notifications-controller-56748c87bd-22rcs -- /usr/local/bin/argocd-notifications trigger get
INFO[0000] serving metrics on port 9001                 
INFO[0000] loading configuration 9001                   
FATA[0000] listen tcp 0.0.0.0:9001: bind: address already in use 
command terminated with exit code 1

There is only one pid in the pod.. argocd-notifications pid 1.

@seonggwonyoon
Copy link

seonggwonyoon commented Jun 8, 2022

I'm having this problem, too

App Name Version
Argo CD v2.3.4+ac8b7df
Build Date 2022-05-18T11:41:37Z
Go Version go1.17.10
Go Compiler gc
Platform linux/amd64
ksonnet v0.13.1
jsonnet v0.18.0
kustomize v4.4.1 2021-11-11T23:36:27Z
Helm v3.8.0+gd141386
kubectl v0.23.1

k exec -it -n argocd argocd-notifications-controller-7bc66689b7-wtbvf -- /usr/local/bin/argocd-notifications trigger get
INFO[0000] serving metrics on port 9001
INFO[0000] loading configuration 9001
FATA[0000] listen tcp 0.0.0.0:9001: bind: address already in use
command terminated with exit code 1

@rahul799 rahul799 changed the title Slack notifications not working Slack notifications not working in argo Jun 10, 2022
@anfallow
Copy link

Hello, any updates or estimates on this fix?

Thanks

@hebestreit
Copy link

This project has moved to the main Argo CD repository which was announced in the README.md.

To test the notification you now have to use following command which will print out details on success or failure.

argocd admin notifications template notify NAME RESOURCE_NAME [flags]

Examples

# Trigger notification using in-cluster config map and secret
argocd admin notifications template notify app-sync-succeeded guestbook --recipient slack:my-slack-channel

# Render notification render generated notification in console
argocd admin notifications template notify app-sync-succeeded guestbook

Find more information in the official documentation:

https://argo-cd.readthedocs.io/en/stable/user-guide/commands/argocd_admin_notifications_template_notify/

Also make sure that the template you're defining as NAME exists in the argocd/argocd-notifications-cm ConfigMap.

@Geethree
Copy link

Geethree commented Jun 24, 2022

Ok thanks @hebestreit Glad the documentation is updated now ;)

This helped me realize I didn't have any triggers or templates set.

TL;DR
I modified my argocd-notifications-cm to be

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
data:
  service.slack: |
    token: $slack-token
  defaultTriggers: |
    - on-deployed
  trigger.on-deployed: |
    - description: Application is synced and healthy. Triggered once per commit.
      oncePer: app.status.sync.revision
      send:
      - app-deployed
      when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
  template.app-deployed: |
    message: |
      {{if eq .serviceType "slack"}}:white_check_mark:{{end}} Application {{.app.metadata.name}} is now running new version of deployments manifests.
    slack:
      attachments: |
        [{
          "title": "{{ .app.metadata.name}}",
          "title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
          "color": "#18be52",
          "fields": [
          {
            "title": "Sync Status",
            "value": "{{.app.status.sync.status}}",
            "short": true
          },
          {
            "title": "Repository",
            "value": "{{.app.spec.source.repoURL}}",
            "short": true
          },
          {
            "title": "Revision",
            "value": "{{.app.status.sync.revision}}",
            "short": true
          }
          {{range $index, $c := .app.status.conditions}}
          {{if not $index}},{{end}}
          {{if $index}},{{end}}
          {
            "title": "{{$c.type}}",
            "value": "{{$c.message}}",
            "short": true
          }
          {{end}}
          ]
        }]

And I have notifications and the argocd admin notifications tooling works =)

@deybhayden
Copy link

Just going to add that I had the same issue as GeeThree - I didn't realize that there were no default Triggers & Templates being shipped with the Notification Controller. Once I updated my helm install with the commented defaults starting here things started working as expected. 👍🏻 I think this issue could be closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants