fix(mcp/k8s): _kubectl_scale 補 validate_deployment_exists dry-run
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
根因:_kubectl_restart 有 dry-run 驗證,_kubectl_scale 完全沒有
→ gitea(docker-compose,不在 K8s)直接被 kubectl scale 執行
→ Deployment 'gitea' not found in namespace 'awoooi-prod'(INC-20260425-3B6C39)
修復:_kubectl_scale 在執行前加 validate_deployment_exists,
K8s 找不到 deployment 時返回 error 而非繼續執行
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -336,6 +336,13 @@ class K8sProvider(MCPToolProvider):
|
||||
if not deployment:
|
||||
return {"error": "Missing 'deployment' parameter"}
|
||||
|
||||
# 2026-04-27 ogt + Claude Sonnet 4.6: 補 dry-run 驗證,與 _kubectl_restart 對齊
|
||||
# 根因:_kubectl_scale 缺 validate_deployment_exists → gitea(docker-compose 服務)
|
||||
# 直接被 kubectl scale → K8s not found 執行失敗(INC-20260425-3B6C39 事故)
|
||||
dry_run = await executor.validate_deployment_exists(deployment, namespace)
|
||||
if not dry_run.passed:
|
||||
return {"error": dry_run.message, "dry_run": False}
|
||||
|
||||
cmd = f"kubectl scale deployment/{deployment} --replicas={replicas} -n {namespace}"
|
||||
result = await executor.execute_kubectl_command(cmd)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user