feat(argocd): recover Telegram notifications (failed/degraded) and prune for polymarket-bot
- Notifications via generic webhook to the Telegram Bot API: the engine's
native telegram service only supports channels and negative group IDs,
so a positive private chat_id never worked ("chat not found").
- Only on-sync-failed and on-health-degraded triggers; on-sync-succeeded
dropped (CI already reports successful deploys).
- Subscribe annotations on polymarket-bot, researchowl and n8n.
- prune: true on polymarket-bot, guarded by Prune=false on the postgres
PVC so removing the manifest from git can never destroy the data.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,9 @@ kind: Application
|
|||||||
metadata:
|
metadata:
|
||||||
name: n8n
|
name: n8n
|
||||||
namespace: argocd
|
namespace: argocd
|
||||||
|
annotations:
|
||||||
|
notifications.argoproj.io/subscribe.on-sync-failed.telegram: "5138407666"
|
||||||
|
notifications.argoproj.io/subscribe.on-health-degraded.telegram: "5138407666"
|
||||||
spec:
|
spec:
|
||||||
destination:
|
destination:
|
||||||
namespace: n8n
|
namespace: n8n
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ kind: Application
|
|||||||
metadata:
|
metadata:
|
||||||
name: polymarket-bot
|
name: polymarket-bot
|
||||||
namespace: argocd
|
namespace: argocd
|
||||||
|
annotations:
|
||||||
|
notifications.argoproj.io/subscribe.on-sync-failed.telegram: "5138407666"
|
||||||
|
notifications.argoproj.io/subscribe.on-health-degraded.telegram: "5138407666"
|
||||||
spec:
|
spec:
|
||||||
destination:
|
destination:
|
||||||
namespace: polymarket-bot
|
namespace: polymarket-bot
|
||||||
@@ -14,4 +17,5 @@ spec:
|
|||||||
targetRevision: main
|
targetRevision: main
|
||||||
syncPolicy:
|
syncPolicy:
|
||||||
automated:
|
automated:
|
||||||
|
prune: true
|
||||||
selfHeal: true
|
selfHeal: true
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ metadata:
|
|||||||
namespace: argocd
|
namespace: argocd
|
||||||
annotations:
|
annotations:
|
||||||
argocd.argoproj.io/tracking-id: researchowl:argoproj.io/Application:argocd/researchowl
|
argocd.argoproj.io/tracking-id: researchowl:argoproj.io/Application:argocd/researchowl
|
||||||
|
notifications.argoproj.io/subscribe.on-sync-failed.telegram: "5138407666"
|
||||||
|
notifications.argoproj.io/subscribe.on-health-degraded.telegram: "5138407666"
|
||||||
spec:
|
spec:
|
||||||
destination:
|
destination:
|
||||||
namespace: researchowl
|
namespace: researchowl
|
||||||
|
|||||||
@@ -8,35 +8,36 @@ metadata:
|
|||||||
name: argocd-notifications-cm
|
name: argocd-notifications-cm
|
||||||
namespace: argocd
|
namespace: argocd
|
||||||
data:
|
data:
|
||||||
service.telegram: |
|
# The native telegram service of the notifications engine only supports
|
||||||
token: $telegram-token
|
# channels (@name) and negative group chat IDs; a positive private chat ID
|
||||||
|
# like ours gets sent as "@<id>" and fails with "chat not found". Workaround:
|
||||||
template.app-sync-succeeded: |
|
# a generic webhook service against the Telegram Bot API, which accepts any
|
||||||
telegram:
|
# chat_id. The service is still named "telegram" so the subscribe annotations
|
||||||
message: |
|
# read naturally.
|
||||||
✅ ArgoCD: {{.app.metadata.name}} sync completado
|
service.webhook.telegram: |
|
||||||
Revisión: {{.app.status.operationState.syncResult.revision | trunc 8}}
|
url: https://api.telegram.org/bot$telegram-token/sendMessage
|
||||||
|
headers:
|
||||||
|
- name: Content-Type
|
||||||
|
value: application/json
|
||||||
|
|
||||||
template.app-sync-failed: |
|
template.app-sync-failed: |
|
||||||
telegram:
|
webhook:
|
||||||
message: |
|
telegram:
|
||||||
❌ ArgoCD: {{.app.metadata.name}} sync fallido
|
method: POST
|
||||||
{{if .app.status.operationState.message}}Error: {{.app.status.operationState.message}}{{end}}
|
body: |
|
||||||
|
{"chat_id": "5138407666", "text": {{toJson (printf "❌ ArgoCD: %s sync fallido\n%s" .app.metadata.name (or .app.status.operationState.message ""))}}}
|
||||||
|
|
||||||
template.app-degraded: |
|
template.app-degraded: |
|
||||||
telegram:
|
webhook:
|
||||||
message: |
|
telegram:
|
||||||
⚠️ ArgoCD: {{.app.metadata.name}} degradada
|
method: POST
|
||||||
Health: {{.app.status.health.status}}
|
body: |
|
||||||
|
{"chat_id": "5138407666", "text": {{toJson (printf "⚠️ ArgoCD: %s degradada\nHealth: %s" .app.metadata.name .app.status.health.status)}}}
|
||||||
trigger.on-sync-succeeded: |
|
|
||||||
- when: app.status.operationState.phase in ['Succeeded']
|
|
||||||
send: [app-sync-succeeded]
|
|
||||||
|
|
||||||
trigger.on-sync-failed: |
|
trigger.on-sync-failed: |
|
||||||
- when: app.status.operationState.phase in ['Error', 'Failed']
|
- when: app.status.operationState != nil && app.status.operationState.phase in ['Error', 'Failed']
|
||||||
send: [app-sync-failed]
|
send: [app-sync-failed]
|
||||||
|
|
||||||
trigger.on-degraded: |
|
trigger.on-health-degraded: |
|
||||||
- when: app.status.health.status == 'Degraded'
|
- when: app.status.health.status == 'Degraded'
|
||||||
send: [app-degraded]
|
send: [app-degraded]
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ apiVersion: v1
|
|||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
|
# Never let ArgoCD prune this PVC: it holds the paper-trading postgres data.
|
||||||
|
argocd.argoproj.io/sync-options: Prune=false
|
||||||
pv.kubernetes.io/bind-completed: 'yes'
|
pv.kubernetes.io/bind-completed: 'yes'
|
||||||
pv.kubernetes.io/bound-by-controller: 'yes'
|
pv.kubernetes.io/bound-by-controller: 'yes'
|
||||||
volume.beta.kubernetes.io/storage-provisioner: rancher.io/local-path
|
volume.beta.kubernetes.io/storage-provisioner: rancher.io/local-path
|
||||||
|
|||||||
Reference in New Issue
Block a user