fix(auto_execute): 替換 action 中的 <deployment_name>/{target}/{namespace} placeholder
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 24s

Nemotron tool calling 生成 <deployment_name> 佔位符未替換
auto_execute 前統一替換所有 {target}/{namespace}/<xxx> 格式

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-10 22:00:19 +08:00
parent 71f0dbf2b5
commit e5f1541d69

View File

@@ -666,6 +666,17 @@ class DecisionManager:
"""
action = token.proposal_data.get("kubectl_command", "")
# 替換所有 placeholder — {target}/{namespace}/<deployment_name> 等
_target = incident.affected_services[0] if incident.affected_services else "unknown"
_ns = "awoooi-prod"
if incident.signals:
_ns = incident.signals[0].labels.get("namespace", "awoooi-prod")
import re as _re
action = action.replace("{target}", _target).replace("{namespace}", _ns)
# <xxx> 格式佔位符 → 用 target 替換
action = _re.sub(r"<deployment_name>", _target, action)
action = _re.sub(r"<[^>]+>", _target, action)
try:
# 延遲導入避免循環依賴
from src.models.approval import ApprovalRequest, ApprovalStatus