-
Notifications
You must be signed in to change notification settings - Fork 140
Description
Description:
We encountered an issue where setting weight of one backendRef to 0 results in translation failing in other backendRefs within that rule.
Ie
apiVersion: aigateway.envoyproxy.io/v1alpha1
kind: AIGatewayRoute
metadata:
name: my-route
namespace: default
spec:
rules:
- matches:
- headers:
- name: ai-model
value: gpt-4
backendRefs:
- name: gcp-backend-1
weight: 0 # ← Weight 0!
- name: gcp-backend-2
weight: 100
Seems the issue stems from how envoy gateway evaluates httproutes w/ weight 0.
ai-gateway/internal/extensionserver/post_translate_modify.go
Lines 210 to 214 in 0a3ada4
| if len(cluster.LoadAssignment.Endpoints) != len(httpRouteRule.BackendRefs) { | |
| s.log.Info("LoadAssignment endpoints length does not match backend refs length", | |
| "cluster_name", cluster.Name, "endpoints_length", len(cluster.LoadAssignment.Endpoints), "backend_refs_length", len(httpRouteRule.BackendRefs)) | |
| return nil | |
| } |
There is a mismatch where cluster.LoadAssignment.Endpoints == 1 and httpRouteRule.BackendRefs == 2. This results in the metadata not being set and to the upstream filter returning early.
I want to say it's related to https://github.com/envoyproxy/gateway/blob/main/internal/gatewayapi/route.go#L1746-L1749
Repro steps:
- Create a routing rule w/ 2 backend refs which requires translation
- Set one of the weights to 0
- Query route
Logs:
2025-12-16T21:16:51Z INFO envoy-gateway-extension-server LoadAssignment endpoints length does not match backend refs length {"cluster_name": "httproute/gateway/gcp.backend/rule/0", "endpoints_length": 1, "backend_refs_length": 2}
Solution idea:
Create a count for backendRef that do not have weights equal to 0.