From 933807056214acfcea04d43cec184fcaafb601d2 Mon Sep 17 00:00:00 2001 From: vibe-code Date: Thu, 13 Aug 2026 10:07:38 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20manual=5Fevict=20key=20=E6=94=B9?= =?UTF-8?q?=E7=94=A8=20config=20model=20=E5=AD=97=E6=AE=B5=E5=85=A8?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E9=98=B2=E8=AF=AF=E4=BC=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 此前 key 用 clean 名(model 去渠道前缀), 同 clean 不同渠道(如 openai/ 前缀同名模型)会被误伤。改为 manual_evict:{raw_model} (config.yaml 完整 model 字段, 含渠道前缀)全匹配, monitored pairs 过滤后仍精确到具体条目。用法: SET manual_evict:volcengine/ 1 --- volc_limit_sync.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/volc_limit_sync.py b/volc_limit_sync.py index c055b2d..c35bd27 100644 --- a/volc_limit_sync.py +++ b/volc_limit_sync.py @@ -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: 1 - # 解除: docker exec litellm_redis redis-cli DEL manual_evict: + # 软踢: docker exec litellm_redis redis-cli SET manual_evict:volcengine/ 1 + # 解除: docker exec litellm_redis redis-cli DEL manual_evict:volcengine/ # 查看: 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)