fix(chat+nim): 修復首席架構師 Review I1-I4 + S3 四項重要問題
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 7m9s
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 7m9s
I1: chat_manager._call_openclaw timeout=30.0 → 讀 settings.OPENCLAW_TIMEOUT I2: nvidia_provider.py stale comment "45" → "55" 對齊 ConfigMap I3: asyncio.shield 移除 — shield 超時後 task 繼續跑但無人等待 (silent leak) I4: ChatManager.__init__ 移除 repo 實例 (leWOOOgo 禁 Service 持有 repository) S3: _check_nemotron_health probe 10s → 25s + /v1/models 輕量端點 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,15 +41,16 @@ class ChatManager:
|
||||
"""AWOOOI 雙 AI 對話管理器"""
|
||||
|
||||
def __init__(self):
|
||||
self.k8s = get_k8s_repository()
|
||||
self.incidents = get_incident_repository()
|
||||
pass # 2026-04-03 ogt: 移除 repo 實例化,leWOOOgo 規範禁止 Service 持有 repository
|
||||
|
||||
async def get_system_context(self) -> str:
|
||||
"""收集系統即時上下文"""
|
||||
now = now_taipei()
|
||||
k8s = get_k8s_repository()
|
||||
incidents = get_incident_repository()
|
||||
|
||||
try:
|
||||
k8s_status = await self.k8s.get_pod_status_summary(namespace="awoooi-prod")
|
||||
k8s_status = await k8s.get_pod_status_summary(namespace="awoooi-prod")
|
||||
cluster_info = f"Cluster: {k8s_status['running']}/{k8s_status['total']} Pods Running"
|
||||
if k8s_status.get('problem_pods'):
|
||||
cluster_info += f", {len(k8s_status['problem_pods'])} 異常"
|
||||
@@ -57,7 +58,7 @@ class ChatManager:
|
||||
cluster_info = "Cluster: 無法取得狀態"
|
||||
|
||||
try:
|
||||
active_incidents = await self.incidents.get_active()
|
||||
active_incidents = await incidents.get_active()
|
||||
if active_incidents:
|
||||
lines = [f"- {inc.incident_id}: {inc.status.value} (SEV {inc.severity.value})"
|
||||
for inc in active_incidents[:3]]
|
||||
@@ -84,9 +85,10 @@ class ChatManager:
|
||||
settings = get_settings()
|
||||
|
||||
openclaw_url = getattr(settings, 'OPENCLAW_URL', 'http://192.168.0.188:8088')
|
||||
openclaw_timeout = float(getattr(settings, 'OPENCLAW_TIMEOUT', 30.0))
|
||||
try:
|
||||
# OpenClaw 沒有通用 chat endpoint,用 analyze/incident 傳入對話內容
|
||||
async with httpx.AsyncClient(timeout=30.0) as client:
|
||||
async with httpx.AsyncClient(timeout=openclaw_timeout) as client:
|
||||
resp = await client.post(
|
||||
f"{openclaw_url}/api/v1/analyze/incident",
|
||||
json={
|
||||
@@ -167,8 +169,9 @@ class ChatManager:
|
||||
)
|
||||
|
||||
# OpenClaw 最多等 40s(含 context 取得時間),NemoClaw 最多等 60s
|
||||
# 2026-04-03 ogt: 移除 asyncio.shield — shield 會在超時後讓 task 繼續跑但無人等待,造成 silent leak
|
||||
try:
|
||||
openclaw_raw = await asyncio.wait_for(asyncio.shield(openclaw_task), timeout=40.0)
|
||||
openclaw_raw = await asyncio.wait_for(openclaw_task, timeout=40.0)
|
||||
except asyncio.TimeoutError:
|
||||
openclaw_raw = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user