From 146b8b668494df0a95fb421cbbfb851a79f3b840 Mon Sep 17 00:00:00 2001 From: li Date: Fri, 7 Aug 2026 20:41:23 +0800 Subject: [PATCH] =?UTF-8?q?revert(grok):=20=E6=92=A4=E5=9B=9E=20405=20?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E7=BA=A7=E8=B8=A2=E5=8F=B7=EF=BC=8C=E5=8F=AA?= =?UTF-8?q?=E4=BF=9D=E7=95=99=20failover=20=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tempUnscheduleGrok 是账号级、全端点、全模型的下线,而 handleGrokAccountUpstreamError 有 8 个调用点(raw chat / Grok 媒体 / CC 管线 / WS HTTP 桥接 / responses), /v1/responses 的 405 只证明该端点缺失,账号在其他端点上仍然健康。 仓库里已有相反的既定不变式:shouldApplyOpenAIAlphaSearchAccountErrorSideEffects 把 404/405 显式排除在账号状态写入之外,注释写明「端点不存在只说明该上游不支持 独立搜索,账号本身健康」。 failover 分类器加 405 单独就能解开 sticky 锁死(调度器选号时会即时改绑 sticky), 账号级冷却不是必需的。「405 不踢号但记住端点能力」按端点级负缓存另行处理。 --- backend/internal/service/openai_gateway_grok.go | 2 -- backend/internal/service/openai_gateway_grok_test.go | 7 ------- 2 files changed, 9 deletions(-) diff --git a/backend/internal/service/openai_gateway_grok.go b/backend/internal/service/openai_gateway_grok.go index 87899c1350..4d367c9aeb 100644 --- a/backend/internal/service/openai_gateway_grok.go +++ b/backend/internal/service/openai_gateway_grok.go @@ -1370,8 +1370,6 @@ func (s *OpenAIGatewayService) handleGrokAccountUpstreamError(ctx context.Contex s.tempUnscheduleGrok(ctx, account, 30*time.Minute, "grok payment required") case http.StatusForbidden: s.tempUnscheduleGrok(ctx, account, 30*time.Minute, "grok access or entitlement denied") - case http.StatusMethodNotAllowed: - s.tempUnscheduleGrok(ctx, account, 30*time.Minute, "grok endpoint not supported (405)") case http.StatusTooManyRequests: // updateGrokUsageSnapshot installs rate-limit state for non-pool accounts. default: diff --git a/backend/internal/service/openai_gateway_grok_test.go b/backend/internal/service/openai_gateway_grok_test.go index 30c25ba586..19942eae7d 100644 --- a/backend/internal/service/openai_gateway_grok_test.go +++ b/backend/internal/service/openai_gateway_grok_test.go @@ -2583,13 +2583,6 @@ func TestHandleGrokAccountUpstreamErrorTempUnschedulesNonRateLimitStates(t *test wantMinCooldown: 2*time.Minute - time.Second, wantMaxCooldown: 2*time.Minute + time.Second, }, - { - name: "method not allowed", - status: http.StatusMethodNotAllowed, - wantReason: "grok endpoint not supported (405)", - wantMinCooldown: 30*time.Minute - time.Second, - wantMaxCooldown: 30*time.Minute + time.Second, - }, } for _, tt := range tests {