fix(governance): skip non-finite slo values
All checks were successful
Code Review / ai-code-review (push) Successful in 10s
CD Pipeline / tests (push) Successful in 1m4s
CD Pipeline / build-and-deploy (push) Successful in 3m18s
CD Pipeline / post-deploy-checks (push) Successful in 1m17s

This commit is contained in:
Your Name
2026-05-14 19:05:16 +08:00
parent d1b0ee7e96
commit 368386abc0
2 changed files with 61 additions and 7 deletions

View File

@@ -399,6 +399,7 @@ class GovernanceAgent:
2026-04-27 P3.4 by Claude — AI SLOADR-100
"""
import httpx
import math
from src.core.config import settings
@@ -457,6 +458,21 @@ class GovernanceAgent:
)
continue
value = float(result_list[0]["value"][1])
if not math.isfinite(value):
results[name] = {
"name": name,
"status": "skipped",
"error": "non_finite_value",
"reason": "prometheus_nan_or_inf",
"hint": "SLO 分母目前沒有足夠事件,等待下一個有效樣本再評估",
}
logger.warning(
"governance_slo_non_finite",
slo=name,
query=query,
value=str(result_list[0]["value"][1]),
)
continue
threshold = hard_red_lines[name]
target = slo_targets[name]
violated = value < threshold