envoyproxy / envoyproxy/gateway
backendRef weights are ignored when ConsistentHash load balancing is configured
- Dominant language
- Go
- Stars
- 3k
- Forks
- 864
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 148
Description
*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*:
```yml
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):
```yml
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.