Skip to content

Weights in aigatewayroutes set to 0 affects translation #1664

@aabchoo

Description

@aabchoo

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.

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:

  1. Create a routing rule w/ 2 backend refs which requires translation
  2. Set one of the weights to 0
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconfigurationEnvoy Proxy Configuration Related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions