fix(llm): is_probe 跳过 mark_exhausted/bump,只留 mark_health (1.1.2)
线上事故回归:面板「测试」按钮走 /_upstream_test 真实转发,账号由 pick 随机 选;上游一旦回耗尽形态(状态码命中 upe 或 body 命中 marker),旧逻辑会把 「管理员手抖点测试」当成「账号额度耗尽」冷却一把好钥匙,恢复要走完整退避/ 探测。13:50 一次面板测试轮把 minimax 三把好 key 全部点进冷却,整池不可用。 * handlers.rs LlmHealthHandler:is_probe URI 前缀请求**不写冷却/耗尽**;只 跑 mark_health(健康展示仍需)。2xx clear_cool 保留——测试成功 = 该账号此刻 健康,是正向证据。bump_acct_load 保留(测试也是真转发,统计有用)。 * tests/llm/e2e.sh:新增「管理台测试按钮不得写路由状态」剧本,6 条断言; fixture probetest 单账号 Bearer probe-dead + exhaust_status=[401] + markers 一并命中——status 通道 + body 通道都能触发,真实分流修复前 cool 必须为 true,修复后为 false;真实流量同时仍正常冷却(不能为避 bug 把真标记 也关掉)。 * tests/llm/fixtures/llm-upstreams.json:加 probetest 槽位(同形 401+marker)。 回归:bash tests/run.sh llm → 270/0 全绿(原 262 + 8)。
This commit is contained in:
1 parent
6081151410
commit
f179e6e987
3 files changed
+38
-1
No files matched your search
@@ -247,10 +247,17 @@ impl HttpRequestHandler for LlmHealthHandler {
|
||||
// (best-effort 撞墙)→ 时间线不动;
|
||||
// * 2xx 且无耗尽信号 → clear_cool:冷却中的账号被探测/转发验证恢复,
|
||||
// 立即清键回队(健康账号无键,remove 返回 false、静默)。
|
||||
//
|
||||
// is_probe(管理台「测试」按钮的内跳)**不写冷却/耗尽**——
|
||||
// 测试账号由 pick 随机选,上游回耗尽形态只说明「这个请求过不了」,
|
||||
// 不能据此认定账号已耗尽。线上事故:13:50 三把好 key 被面板测试轮
|
||||
// 点进冷却,整池不可用,恢复要走完整退避。mark_health 与
|
||||
// bump_acct_load 照常(测试也是真转发,有统计意义);
|
||||
// 2xx clear_cool 也保留——测试成功 = 该账号此刻健康(正向证据)。
|
||||
let (status_list, _) = upstreams::read_upe(&slot);
|
||||
let status_exhausted = status_list.iter().any(|&s| s == code);
|
||||
let body_exhausted = usage_filter::take_exhausted(r);
|
||||
if status_exhausted || body_exhausted {
|
||||
if !is_probe && (status_exhausted || body_exhausted) {
|
||||
upstreams::mark_exhausted(&slot, idx, now);
|
||||
upstreams::bump_acct_exhaust(&slot, idx, now);
|
||||
} else if (200..300).contains(&code) {
|
||||
|
||||
@@ -852,6 +852,24 @@ ck "★probe 投影:#1 仍在冷却(退避持续)" true "$(acct_view "$UPS
|
||||
ck "probe #0 至少记 1 次耗尽" yes "$([ "$(acct_view "$UPS2" probe 0 load.exhausts)" -ge 1 ] && echo yes || echo no)"
|
||||
ck "probe #1 至少记 3 次耗尽(标记+两轮探测)" yes "$([ "$(acct_view "$UPS2" probe 1 load.exhausts)" -ge 3 ] && echo yes || echo no)"
|
||||
|
||||
# ---- 管理台「测试」按钮不得写路由状态(线上事故回归)----
|
||||
# 事故复现:面板测试走 /_upstream_test,账号由 pick 随机选;上游一旦回 401+marker,
|
||||
# 旧逻辑会把"管理员手抖点了一下测试"当成"这个账号额度耗尽",冷却一张好钥匙,
|
||||
# 恢复要走完一轮退避/探测。fixture `probetest`:单账号 Bearer probe-dead
|
||||
# (上游靶机识别后永远回 401+`status_code:1004` 标记),exhaust_status=[401] 让
|
||||
# status 通道也命中——彻底钉死「测试按钮不写冷却」这条。
|
||||
TB=$(code -b "$JAR" -X POST "$API/api/admin/upstreams/test?slot=probetest" -H 'Content-Type: application/json' -d "$PING")
|
||||
ck "probetest admin test → 上游真实 401 透传" 401 "$TB"
|
||||
UPS_PT=$(curl -s -b "$JAR" $API/api/admin/upstreams)
|
||||
ck "★admin test 后账号未进冷却(冷却不被测试按钮污染)" false "$(acct_view "$UPS_PT" probetest 0 cooled)"
|
||||
ck "★admin test 不记录耗尽计数" 0 "$(acct_view "$UPS_PT" probetest 0 load.exhausts)"
|
||||
# 真实流量同形态 → 标记通道必须照常工作(不能为避 bug 把真标记也关掉)
|
||||
PT1=$(mh probetest probetest-model)
|
||||
ck "probetest 真实流量 → 401(标记通道触发)" 401 "$(echo "$PT1" | awk '/^HTTP/{print $2}')"
|
||||
UPS_PT2=$(curl -s -b "$JAR" $API/api/admin/upstreams)
|
||||
ck "★真实流量 401+marker → 进冷却(标记通道保留)" true "$(acct_view "$UPS_PT2" probetest 0 cooled)"
|
||||
ck "★真实流量耗尽计数 ≥1" yes "$([ "$(acct_view "$UPS_PT2" probetest 0 load.exhausts)" -ge 1 ] && echo yes || echo no)"
|
||||
|
||||
# ---- auth 规范化(normalize_auth)----
|
||||
# fixture `normalize` 账号 auth 写成裸 key(`sk-NORM-NO-SCHEME`,无 `Bearer `),
|
||||
# 期望:转发时网关自动补 `Bearer `,靶机实收完整头值(不会因缺 scheme 触发 1004)。
|
||||
|
||||
@@ -87,5 +87,17 @@
|
||||
"enabled": true,
|
||||
"note": "双协议地址验证:OpenAI 路径 /api/coding/paas/v4 与 Anthropic /api/anthropic 完全不同,各走各的(智谱真实形态)",
|
||||
"created_at": 1757500000
|
||||
},
|
||||
"probetest": {
|
||||
"base": "http://127.0.0.1:18999",
|
||||
"models": ["probetest-model"],
|
||||
"enabled": true,
|
||||
"accounts": [
|
||||
{"auth": "Bearer probe-dead", "note": "永远耗尽(管理测试隔离剧本用)", "resets": []}
|
||||
],
|
||||
"exhaust_status": [401],
|
||||
"exhaust_markers": ["\"status_code\":1004"],
|
||||
"note": "管理台「测试」按钮不得写冷却/耗尽状态(真实事故回归);同形态真实流量进来仍照常标记",
|
||||
"created_at": 1757500000
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user