feat(api): Phase 18.3 K8s Executor 整合自動修復
All checks were successful
E2E Health Check / e2e-health (push) Successful in 17s

2026-03-31 Claude Code (統帥批准)

新增功能:
- execute_auto_repair() 實際執行 K8s 操作
  - restart_deployment: rollout restart
  - restart_pod: 刪除 Pod 觸發重建
  - clear_cache: 安全清理 Redis 快取

安全機制:
- _check_repair_cooldown(): 防止修復風暴
  - 同一資源 5 分鐘內最多修復 3 次
  - 超過限制升級為 MEDIUM 風險
  - Redis 計數器 + 自動過期

修復閉環完整流程:
執行失敗 → FailureWatcher → AI 分析 → 風險評估
├─ LOW + 冷卻期內 → 自動修復 → 揭露通知
└─ MEDIUM/CRITICAL 或超限 → Telegram 請求授權

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-31 12:10:52 +08:00
parent 15fa77f9b8
commit 770586dd85
2 changed files with 159 additions and 17 deletions

View File

@@ -508,13 +508,18 @@ class IFailureWatcher(Protocol):
self,
audit_log_id: str,
repair_strategy: str,
failure_data: dict | None = None,
) -> tuple[bool, str]:
"""
執行自動修復 (僅限 LOW 風險)
Phase 18.3: K8s Executor 整合
2026-03-31 Claude Code (統帥批准)
Args:
audit_log_id: 原始失敗的 AuditLog ID
repair_strategy: 修復策略
failure_data: 失敗詳情 (含 target_resource, namespace)
Returns:
(success, result_message)