From 7c4b36c2cdb0426259458d08d8f0a746c8e2af89 Mon Sep 17 00:00:00 2001 From: OG T Date: Sun, 12 Apr 2026 13:41:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(flywheel):=20Phase=201=20=E2=80=94=20?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=208be87b0=20+=20debounce=2030min=20+=20alert?= =?UTF-8?q?name=20NULL=20=E4=BF=AE=E5=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ADR-073 Phase 1 三項修復: 1. k8s/kustomization.yaml: newTag a86ecf3 → 8be87b0 - 解封 _collect_mcp_context + auto_approve + DESTRUCTIVE_PATTERNS - 這是飛輪解封的關鍵 2. webhooks.py: DEBOUNCE_WINDOW_MINUTES 5 → 30 - 防止同一問題每 5 分鐘重建 Incident,改為 30 分鐘收斂窗口 3. incident_repository.py: signals JSONB 補充 alertname key - signal.model_dump() 只有 alert_name,DB query 用 signals->0->>'alertname' - 補充 alertname alias,修復 132 筆 incidents.alertname = NULL 根因 Co-Authored-By: Claude Sonnet 4.6 --- apps/api/src/api/v1/webhooks.py | 4 ++-- apps/api/src/repositories/incident_repository.py | 8 +++++++- k8s/awoooi-prod/kustomization.yaml | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/api/src/api/v1/webhooks.py b/apps/api/src/api/v1/webhooks.py index e4948df8..556492ce 100644 --- a/apps/api/src/api/v1/webhooks.py +++ b/apps/api/src/api/v1/webhooks.py @@ -462,8 +462,8 @@ async def verify_webhook_signature( # generate_alert_fingerprint 已封裝為 AlertAnalyzer.generate_fingerprint (首席架構師 v1.2 2026-04-01 Asia/Taipei) -# 戰略 B: 滑動時間窗 (5 分鐘) -DEBOUNCE_WINDOW_MINUTES = 5 +# 戰略 B: 滑動時間窗 (ADR-073: 5 分鐘改 30 分鐘,防同一問題反覆重建 Incident,2026-04-12 ogt) +DEBOUNCE_WINDOW_MINUTES = 30 # ============================================================================= diff --git a/apps/api/src/repositories/incident_repository.py b/apps/api/src/repositories/incident_repository.py index 85620339..6ff69bb5 100644 --- a/apps/api/src/repositories/incident_repository.py +++ b/apps/api/src/repositories/incident_repository.py @@ -65,7 +65,13 @@ def _incident_to_record_data(incident: Incident) -> dict[str, Any]: "incident_id": incident.incident_id, "status": incident.status.value, "severity": incident.severity.value, - "signals": [s.model_dump() for s in incident.signals], + "signals": [ + { + **s.model_dump(), + "alertname": s.alert_name, # ADR-073: DB query 用 signals->0->>'alertname',補充 alias + } + for s in incident.signals + ], "affected_services": incident.affected_services, "proposal_ids": incident.proposal_ids, "created_at": incident.created_at, diff --git a/k8s/awoooi-prod/kustomization.yaml b/k8s/awoooi-prod/kustomization.yaml index 2b8adc39..e135dd02 100644 --- a/k8s/awoooi-prod/kustomization.yaml +++ b/k8s/awoooi-prod/kustomization.yaml @@ -38,7 +38,7 @@ resources: images: - name: 192.168.0.110:5000/library/api:IMAGE_TAG_PLACEHOLDER newName: 192.168.0.110:5000/awoooi/api - newTag: a86ecf32a2e7be70b2d130fbadd9e9ad655ea5e1 + newTag: 8be87b0f32a7430d86e93b9be63677c0e498bb79 - name: 192.168.0.110:5000/library/web:IMAGE_TAG_PLACEHOLDER newName: 192.168.0.110:5000/awoooi/web - newTag: a86ecf32a2e7be70b2d130fbadd9e9ad655ea5e1 + newTag: 8be87b0f32a7430d86e93b9be63677c0e498bb79