fix(failover): do not trip targets on a gRPC message size limit

ResourceExhausted is retried and trips the target, which is right for a
rate limit or an out-of-memory backend. A payload over the gRPC message
cap is ResourceExhausted too, but every target rejects it the same way,
so it tripped the whole chain. Classify it as a request error.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto committed 2026-09-27 07:42:21 +00:00
1 parent 5ed67be0bf
commit e61bd2d78e
2 files changed
+9

No files matched your search

+5
View File
@@ -22,6 +22,11 @@ var requestErrorMarkers = []string{
"exceeds the available context size",
"is larger than the max context size",
"maximum context length",
// A payload over the gRPC message cap is ResourceExhausted too, but it
// is the request's size, not the target's load: every target has the
// same cap.
"larger than max",
"gRPC message limit exceeded",
}
// IsRetryable reports whether a failed attempt should move to the next
+4
View File
@@ -36,6 +36,10 @@ var _ = DescribeTable("IsRetryable",
Entry("cloud-proxy upstream 503", errors.New("cloud-proxy: upstream 503: no healthy nodes"), 0, true),
Entry("cloud-proxy upstream 429 stays 4xx", errors.New("cloud-proxy: upstream 429: slow down"), 0, false),
Entry("context overflow", errors.New("the request exceeds the available context size"), 0, false),
Entry("grpc received message over the size limit", grpcstatus.Error(codes.ResourceExhausted, "grpc: received message larger than max (60000000 vs. 52428800)"), 0, false),
Entry("grpc sent message over the size limit", grpcstatus.Error(codes.ResourceExhausted, "grpc: trying to send message larger than max (60000000 vs. 52428800)"), 0, false),
Entry("embeddings over the gRPC message limit", fmt.Errorf("conversation too long for per-token embeddings (gRPC message limit exceeded): %w",
grpcstatus.Error(codes.ResourceExhausted, "grpc: received message larger than max (1 vs. 0)")), 0, false),
Entry("dial error", errors.New("dial tcp 10.0.0.1:8080: connect: connection refused"), 0, true),
)