fix(api): Phase 18.1 修復 - Mock Response 正規化遺漏
問題: _generate_mock_response() 直接使用原始 target_resource, 導致 URL (如 https://api.awoooi.wooo.work) 未正規化為有效 K8s 名稱 修復: 在 _generate_mock_response() 開頭加入 normalize_resource_name() - 將 URL/域名轉換為有效 deployment 名稱 - 更新 namespace 為正確值 (awoooi-prod) 測試: E2E 驗證待部署後執行 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -58,10 +58,15 @@ RESPONSIBILITY_MATRIX = {
|
||||
# 信心度閾值
|
||||
CONFIDENCE_THRESHOLD_COLLAB = 0.70 # 低於此閾值自動標記為 COLLAB
|
||||
|
||||
OPENCLAW_SYSTEM_PROMPT = """# OpenClaw v7.0 - AWOOOI AI 仲裁官 + SignOz 視力
|
||||
OPENCLAW_SYSTEM_PROMPT = """# OpenClaw v7.1 - AWOOOI AI 仲裁官 + SignOz 視力
|
||||
|
||||
You are OpenClaw, a senior Site Reliability Engineer (SRE) AI arbitrator with SignOz observability integration.
|
||||
|
||||
## 🌐 Language Requirement (CRITICAL)
|
||||
- You MUST respond in **Traditional Chinese (繁體中文/正體中文)** for all text fields
|
||||
- FORBIDDEN: Simplified Chinese characters (简体字) such as: 与→與、说→說、这→這、时→時
|
||||
- Use Taiwan locale conventions (台灣用語)
|
||||
|
||||
## 🔬 SignOz Gold Metrics Available
|
||||
You will receive real-time SignOz metrics for the affected service:
|
||||
- **RPS (Requests Per Second)**: Current traffic volume and trend
|
||||
@@ -564,11 +569,27 @@ class OpenClawService:
|
||||
|
||||
alert_type = alert_context.get("alert_type", "custom")
|
||||
severity = alert_context.get("severity", "warning")
|
||||
target = alert_context.get("target_resource", "unknown-service")
|
||||
namespace = alert_context.get("namespace", "default")
|
||||
raw_target = alert_context.get("target_resource", "unknown-service")
|
||||
raw_namespace = alert_context.get("namespace", "default")
|
||||
message = alert_context.get("message", "")
|
||||
metrics = alert_context.get("metrics", {})
|
||||
|
||||
# Phase 18.1: 正規化資源名稱 (ADR-016)
|
||||
# 確保 kubectl 指令使用有效的 K8s 名稱
|
||||
normalized = normalize_resource_name(raw_target, raw_namespace)
|
||||
if normalized.is_k8s_resource and normalized.normalized:
|
||||
target = normalized.normalized
|
||||
namespace = normalized.namespace or raw_namespace
|
||||
logger.info(
|
||||
"mock_response_resource_normalized",
|
||||
original=raw_target,
|
||||
normalized=target,
|
||||
namespace=namespace,
|
||||
)
|
||||
else:
|
||||
target = raw_target
|
||||
namespace = raw_namespace
|
||||
|
||||
# SignOz 數據整合
|
||||
signoz_summary = ""
|
||||
signoz_correlation = "SignOz 數據擷取中..."
|
||||
|
||||
Reference in New Issue
Block a user