Skip to content

backendRef weights are ignored when ConsistentHash load balancing is configured #9775

Description

@CodePrometheus

Description:
We split traffic across two backendRefs (weights 5 / 95) and attach a BackendTrafficPolicy with loadBalancer.type: ConsistentHash on a per-user header, so that a fixed slice of users consistently lands on the canary backend.

But neither the weights nor the pinning takes effect: traffic does not follow the configured 5 / 95, and the same client is served by both backends over time, so no client is pinned.

The generated config points at the reason, the two backendRefs become two weighted localities inside a single cluster, but locality weighting is never enabled on the Maglev policy, so those weights are simply ignored.

Repro steps:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: split
  namespace: default
spec:
  parentRefs:
    - name: eg
  rules:
    - backendRefs:
        - name: backend-a
          port: 3000
          weight: 5
        - name: backend-b
          port: 3000
          weight: 95
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
  name: split-hash
  namespace: default
spec:
  targetRefs:
    - group: gateway.networking.k8s.io
      kind: HTTPRoute
      name: split
  loadBalancer:
    type: ConsistentHash
    consistentHash:
      type: Headers
      headers:
        - name: x-user-id

Generated cluster (abridged config_dump):

name: httproute/default/split/rule/0
lb_policy: MAGLEV
load_balancing_policy:
  policies:
    - typed_extension_config:
        name: envoy.load_balancing_policies.maglev
        typed_config: {"@type": type.googleapis.com/envoy.extensions.load_balancing_policies.maglev.v3.Maglev}   # no locality_weighted_lb_config
load_assignment:
  endpoints:
    - locality: {region: ".../rule/0/backend/0"}
      load_balancing_weight: 5
    - locality: {region: ".../rule/0/backend/1"}
      load_balancing_weight: 95

Environment:
Envoy Gateway: main.
Envoy Proxy: v1.37.1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions