ArgoCD Notifications 채널 변경 시 알림이 폭주하는 이유

ArgoCD Notifications의 Slack 구독 채널만 바꾸고 helm upgrade를 실행했다. 그러자 새로 배포하지도 않은 정상 Application들의 “배포 성공” 알림이 한꺼번에 날아왔다.


구독 채널 변경과 전체 Application 재평가

ArgoCD Notifications는 Helm values의 subscriptions 필드에서 알림을 받을 Slack 채널을 지정한다. 아래는 실제 설정이다.

subscriptions:
  - recipients:
      - slack:C02XXXXXXXX  # 변경 후
    triggers:
      - on-deployed-single
      - on-sync-failed
      - on-health-degraded-single

기존 채널(C01XXXXXXXX)을 새 채널(C02XXXXXXXX)로 바꾼 뒤 helm upgrade를 실행했다. notification controller는 argocd-notifications-cm ConfigMap이 바뀐 것을 감지하면 캐시를 비우고 모든 Application을 다시 평가한다.


채널 ID를 포함하는 oncePer 중복 판정 구조

ArgoCD Notifications의 trigger에는 같은 조건으로 알림을 한 번만 보내기 위한 oncePer 필드가 있다.

trigger.on-deployed-single: |
  - when: >
      app.status.operationState.phase in ['Succeeded']
      and app.status.health.status == 'Healthy'
      and app.status.operationState.syncResult.revision != ''
    oncePer: app.status.operationState.syncResult.revision
    send: [app-deployed]

oncePer: app.status.operationState.syncResult.revision은 같은 Git revision에는 알림을 한 번만 보내라는 뜻이다. revision만 같으면 다시 보내지 않을 것 같지만, 컨트롤러는 중복 판정 키를 revision만으로 만들지 않는다.

notification controller는 알림 발송 이력을 Application 리소스의 annotation에 저장한다.

notified.notifications.argoproj.io

이 annotation의 키 구조는 다음과 같다.

{revision}:{trigger}:{condition_hash}:slack:{channel_id}

실제 값을 확인하면 구조가 명확해진다.

{
  "dad316da...:on-deployed-single:[0].3Vp...:slack:C01XXXXXXXX": 1773300361,
  "dad316da...:on-deployed-single:[0].3Vp...:slack:C02XXXXXXXX": 1773723412
}

같은 revision(dad316da...)에 대해 두 개의 키가 존재한다. 하나는 기존 채널이고 다른 하나는 새 채널이다. 컨트롤러가 채널 ID를 중복 판정 키에 넣기 때문에, 같은 revision이라도 채널이 바뀌면 아직 보내지 않은 알림으로 판단한다.


알림 폭주의 전체 흐름

채널 변경 후 발생하는 과정을 순서대로 정리하면 다음과 같다.

sequenceDiagram
    participant Helm as helm upgrade
    participant NC as Notification Controller
    participant App as Application N개
    participant Slack as 신규 Slack 채널

    Helm->>NC: ConfigMap 변경 감지<br>(채널 C01... → C02...)
    NC->>NC: 캐시 무효화 + 전체 앱 재평가
    loop 모든 Application
        NC->>App: notified annotation 조회
        Note over NC, App: 키에 C02...가 없음<br>→ "미발송"으로 판정
        NC->>NC: trigger 조건 평가<br>(Healthy + Succeeded = true)
        NC->>Slack: 🚀 배포 성공 알림 발송
        NC->>App: annotation에 C02... 키 추가
    end

notification controller 로그에도 이 과정이 그대로 남는다. helm upgrade 직후 invalidated cache가 찍히고, 컨트롤러가 모든 Application을 순서대로 다시 처리(Start processing)한다.

{"msg":"invalidated cache for resource in namespace: argocd with the name: argocd-notifications-cm"}
{"msg":"invalidated cache for resource in namespace: argocd
  with the name: notification-token-secret"}

이미 Healthy 상태인 앱들의 trigger 조건은 true가 된다. 컨트롤러는 기존 채널에는 이미 보냈다고 보고(already sent) 건너뛰지만, 새 채널로는 알림을 새로 보낸다.


알림 발송 대상이 되는 Application 조건

“알림 폭주”라고 했지만 실제로는 조건을 만족하는 앱만 알림을 보낸다. trigger 조건은 다음과 같다.

when: >
  app.status.operationState.phase in ['Succeeded']
  and app.status.health.status == 'Healthy'
  and app.status.operationState.syncResult.revision != ''

세 조건을 모두 만족할 때만 알림이 나간다. status.operationState가 없거나(revision == '') 현재 Healthy가 아니면 컨트롤러가 trigger를 false로 보고 알림을 보내지 않는다. 실제 로그에서도 operationState 조건에 걸린 reloader, external-secrets 같은 인프라 앱들은 false가 나왔다.

결국 한 번이라도 Sync에 성공했고 현재 Healthy 상태인 앱만 새 채널로 알림을 보낸다. 프로덕션 클러스터에서는 7개 서비스 앱과 일부 공통 앱이 여기에 해당했다.


채널 변경 시 알림 폭주를 막는 방법

ArgoCD Notifications는 oncePer 중복 판정 키를 revision + trigger + condition + destination 조합으로 만든다. 채널 변경은 이 조합에서 destination을 바꾸므로, 컨트롤러가 기존 Healthy 앱들에 알림을 다시 보내는 동작은 설계대로다.

따라서 운영 중인 클러스터에서 알림 채널을 변경할 때는 두 가지 선택지가 있다.

  1. 변경 대상 앱 수가 적다면 팀에 일회성 알림 재발송을 사전 고지한 뒤 helm upgrade를 진행한다.
  2. 알림이 너무 많아 한꺼번에 오는 일을 막고 싶다면 helm upgrade 전에 컨트롤러 레플리카를 0으로 내린다. 이어서 Application들의 notified annotation에 들어 있는 기존 채널 ID를 새 채널 ID로 바꾼 뒤 컨트롤러를 다시 올린다.

참고 자료