fix: manual_evict key 改用 config model 字段全匹配防误伤
此前 key 用 clean 名(model 去渠道前缀), 同 clean 不同渠道(如
openai/ 前缀同名模型)会被误伤。改为 manual_evict:{raw_model}
(config.yaml 完整 model 字段, 含渠道前缀)全匹配, monitored pairs
过滤后仍精确到具体条目。用法:
SET manual_evict:volcengine/<model> 1
This commit is contained in:
+9
-7
@@ -862,8 +862,8 @@ def _check_request_block(model_name, reserve=0.0):
|
||||
返回 (clean_model, usage, limit) 表示超限,None 表示放行。
|
||||
fail-closed:Redis 不可用 / 限额获取失败 / 读取异常时,对监控条目返回
|
||||
(clean_model, -1, -1) 标记拒绝(宁可错杀,不可漏放);非监控条目不受影响。
|
||||
手动软踢:Redis key manual_evict:{clean} 存在时返回 (clean_model, -2, -2)
|
||||
恒 429,由运维 docker exec 设置/删除(见函数内注释)。
|
||||
手动软踢:Redis key manual_evict:{config model 字段全名} 存在时返回
|
||||
(clean_model, -2, -2) 恒 429,由运维 docker exec 设置/删除(见函数内注释)。
|
||||
"""
|
||||
if not LITELLM_AVAILABLE:
|
||||
return None
|
||||
@@ -905,16 +905,18 @@ def _check_request_block(model_name, reserve=0.0):
|
||||
)
|
||||
return (clean, -1, -1)
|
||||
|
||||
# ── 手动软踢:Redis manual_evict:{clean} 存在 → 恒 429 (usage=-2, limit=-2) ──
|
||||
# ── 手动软踢:Redis manual_evict:{raw_model} 存在 → 恒 429 (usage=-2, limit=-2) ──
|
||||
# 运维手段:模型踩采集上限/异常时无需等同步阈值,直接 docker exec 踢出:
|
||||
# 软踢: docker exec litellm_redis redis-cli SET manual_evict:<clean_model> 1
|
||||
# 解除: docker exec litellm_redis redis-cli DEL manual_evict:<clean_model>
|
||||
# 软踢: docker exec litellm_redis redis-cli SET manual_evict:volcengine/<model> 1
|
||||
# 解除: docker exec litellm_redis redis-cli DEL manual_evict:volcengine/<model>
|
||||
# 查看: docker exec litellm_redis redis-cli KEYS manual_evict:*
|
||||
# key 用 config.yaml 中该条目的完整 model 字段(含渠道前缀)全匹配,
|
||||
# 杜绝同名 clean 但不同渠道的模型被误伤(monitored pairs 过滤后仍精确到条目)。
|
||||
# key 落在 Redis 持久卷,重启 litellm 后仍生效(不依赖 router 内存态),
|
||||
# 显式 DEL 才恢复。天然幂等:已存在时每次请求恒 429。
|
||||
if redis_client.get(f"manual_evict:{clean}"):
|
||||
if redis_client.get(f"manual_evict:{raw_model}"):
|
||||
log(
|
||||
f"🚫 [MANUAL-EVICT] {clean} manually soft-evicted (429)",
|
||||
f"🚫 [MANUAL-EVICT] {raw_model} manually soft-evicted (429)",
|
||||
level="WARNING",
|
||||
)
|
||||
return (clean, -2, -2)
|
||||
|
||||
Reference in New Issue
Block a user