fix(aiops-p0): 六大病根 P0 全面修復(ADR-092 B4)
【P0.1】knowledge_extractor_service.py:210 — AttributeError 修復 - Signal.description 欄位不存在(100% 失敗,KM 每天+5 根因) - 改用 alert_name + annotations.summary 拼接文字 【P0.2+P0.3】Gate 9+11 唯讀指令鬆綁 - blast_radius_calculator: kubectl get/top/describe/logs/version → score=1(非 50) - operation_parser: 增加 INVESTIGATE 類型識別(唯讀 kubectl 不回 None) - executor.py: OperationType 新增 INVESTIGATE enum - approval_execution.py: INVESTIGATE 路徑直接呼叫 execute_kubectl_command 【P0.4】MCP SSH/K8s Provider 修復 - decision_manager: params= → parameters=(符合 MCPToolProvider.execute 簽名) - decision_manager: MCPToolResult .get() → .success/.output(dataclass 用法) - decision_manager + ssh_provider: 補入 hosts 120/121(原 default 缺失) - auto_approve: phase2_agent_debate source bypass confidence 閾值 【P0.5】告警規則語義矛盾修復 - alert_rules.yaml: 8 條 kubectl 查詢規則 RESTART_DEPLOYMENT → NO_ACTION (CrashLoopBackOff/PostgreSQL 連線/慢查詢/MinIO 磁碟/K3s 節點/告警鏈路/SSL/CoreDNS 等) - incident_service.py: cAdvisor/CoreDNS 從 general 拆出獨立分類 【P0.6】proactive_inspector 動態基線 PromQL 全修 - 5 個 MONITORED_METRICS PromQL 全部修正(cadvisor label/datname/blackbox) - db_connection_pool: datname="awoooi" → "awoooi_prod" - http_error_rate: 無效 http_requests_total → blackbox probe_success - cpu/memory: namespace label → name=~"k8s_api_awoooi-api.*" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2188,7 +2188,8 @@ class DecisionManager:
|
||||
try:
|
||||
ssh = self._ssh
|
||||
# C4: 未知主機記錄 warning(不靜默跳過)
|
||||
_KNOWN_HOSTS = ("192.168.0.188", "192.168.0.110")
|
||||
# P0.4 fix 2026-04-24 ogt + Claude Sonnet 4.6: 補入 120/121,與 ssh_provider default 對齊
|
||||
_KNOWN_HOSTS = ("192.168.0.188", "192.168.0.110", "192.168.0.120", "192.168.0.121")
|
||||
if ssh.enabled and host not in _KNOWN_HOSTS:
|
||||
logger.warning("mcp_context_unknown_host", host=host, known=_KNOWN_HOSTS)
|
||||
if ssh.enabled and host in _KNOWN_HOSTS:
|
||||
@@ -2197,23 +2198,27 @@ class DecisionManager:
|
||||
status_result = await asyncio.wait_for(
|
||||
ssh.execute(
|
||||
tool_name="ssh_get_container_status",
|
||||
params={"host": host, "container_name": container},
|
||||
# P0.4 fix 2026-04-24 ogt + Claude Sonnet 4.6: params= → parameters=(符合 MCPToolProvider.execute 簽名)
|
||||
parameters={"host": host, "container_name": container},
|
||||
),
|
||||
timeout=_MCP_TIMEOUT,
|
||||
)
|
||||
if status_result.get("success"):
|
||||
ctx_parts.append(f"[SSH] 容器 {container} 狀態: {status_result.get('output', '')[:300]}")
|
||||
# P0.4 fix 2026-04-24 ogt + Claude Sonnet 4.6: MCPToolResult 是 dataclass,用 .success/.output 而非 .get()
|
||||
if status_result.success:
|
||||
ctx_parts.append(f"[SSH] 容器 {container} 狀態: {(status_result.output or '')[:300]}")
|
||||
# 查主機資源
|
||||
if "CpuLoad" in alertname or "Memory" in alertname:
|
||||
top_result = await asyncio.wait_for(
|
||||
ssh.execute(
|
||||
tool_name="ssh_get_top_processes",
|
||||
params={"host": host, "top_n": 5},
|
||||
# P0.4 fix 2026-04-24 ogt + Claude Sonnet 4.6: params= → parameters=
|
||||
parameters={"host": host, "top_n": 5},
|
||||
),
|
||||
timeout=_MCP_TIMEOUT,
|
||||
)
|
||||
if top_result.get("success"):
|
||||
ctx_parts.append(f"[SSH] 主機 {host} Top processes: {top_result.get('output', '')[:300]}")
|
||||
# P0.4 fix 2026-04-24 ogt + Claude Sonnet 4.6: MCPToolResult dataclass 用 .success/.output
|
||||
if top_result.success:
|
||||
ctx_parts.append(f"[SSH] 主機 {host} Top processes: {(top_result.output or '')[:300]}")
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning("mcp_context_ssh_timeout", alertname=alertname, host=host, timeout=_MCP_TIMEOUT)
|
||||
except Exception as e:
|
||||
@@ -2229,12 +2234,14 @@ class DecisionManager:
|
||||
events_result = await asyncio.wait_for(
|
||||
k8s.execute(
|
||||
tool_name="k8s_get_events",
|
||||
params={"namespace": ns, "field_selector": f"involvedObject.name={pod}"},
|
||||
# P0.4 fix 2026-04-24 ogt + Claude Sonnet 4.6: params= → parameters=
|
||||
parameters={"namespace": ns, "field_selector": f"involvedObject.name={pod}"},
|
||||
),
|
||||
timeout=_MCP_TIMEOUT,
|
||||
)
|
||||
if events_result.get("success"):
|
||||
ctx_parts.append(f"[K8s] Pod {pod} 事件: {events_result.get('output', '')[:300]}")
|
||||
# P0.4 fix 2026-04-24 ogt + Claude Sonnet 4.6: MCPToolResult 是 dataclass,用 .success/.output
|
||||
if events_result.success:
|
||||
ctx_parts.append(f"[K8s] Pod {pod} 事件: {(events_result.output or '')[:300]}")
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning("mcp_context_k8s_timeout", alertname=alertname, timeout=_MCP_TIMEOUT)
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user