Repository navigation
Description
Description:
I had filed issue related to weighted backends (e.g., canary purposes). It has been fixed, but it doesn't appear to solve the problem.
Given the scenario for canary purposes:
- Backend A currently serving production traffic. Set the weight to
100. - Preparing backend B for canary deployment. Set the weight to
0. - Increase gradually backend B weight according to backend A weight. For example 100-0, 95-5, 90-10, 80-20, and so forth.
But it turned on point 2, setting the weight to 0 rejected by Envoy Gateway, as it seems that Envoy Gateway uses load_balancing_weight field in endpoints under ClusterLoadAssigment which explicitly mentioned at least 1 is provided.
load_balancing_weight
(UInt32Value) Optional: Per priority/region/zone/sub_zone weight; at least 1. The load balancing weight for a locality is divided by the sum of the weights of all localities at the same priority level to produce the effective percentage of traffic for the locality. The sum of the weights of all localities at the same priority level must not exceed uint32_t maximal value (4294967295).
From Envoy Gateway logs, you can see errors like below:
invalid LocalityLbEndpoints.LoadBalancingWeight: value must be greater than or equal to 1
Proposal:
FWIW, it looks like for the weighted backend requirement would be better to utilize the WeightedCluster component as pointed out by @lemonlinger.
AFAIK, Istio did this for weighted backends.
Repro steps:
- Having 2 different backends on HTTPRoute.
- One backend set the weight to 100, the other to 0.
- You will see error logged by Envoy Gateway like above.
- And the endpoint won't be available in Envoy.
Environment:
Latest
Logs:
Full error log:
2024-01-24T07:42:58.163Z ERROR watchable message/watchutil.go:56 observed an error {"runner": "xds-translator", "error": "validation failed for xds resource cluster_name:\"httproute/envoy-gateway-system/sample/rule/0\" endpoints:{locality:{region:\"httproute/envoy-gateway-system/sample/rule/0/backend/0\"} lb_endpoints:{endpoint:{address:{socket_address:{address:\"10.100.0.85\" port_value:8080}}} load_balancing_weight:{value:1}} load_balancing_weight:{value:100}} endpoints:{locality:{region:\"httproute/envoy-gateway-system/sample/rule/0/backend/1\"} lb_endpoints:{endpoint:{address:{socket_address:{address:\"10.100.0.77\" port_value:3000}}} load_balancing_weight:{value:1}} lb_endpoints:{endpoint:{address:{socket_address:{address:\"10.100.0.77\" port_value:3000}}} load_balancing_weight:{value:1}} load_balancing_weight:{}}, err: invalid ClusterLoadAssignment.Endpoints[1]: embedded message failed validation | caused by: invalid LocalityLbEndpoints.LoadBalancingWeight: value must be greater than or equal to 1"}
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
ardikabs commentedon Jan 24, 2024
Additionally, using WeightedCluster will add a possibility of using a different setup between the backends, for instance, a circuit breaker added for the other backend than the existing one.
arkodg commentedon Jan 24, 2024
thanks for finding this bug !
WeightedCluster has way more issues associated with it, prefer this simpler approach
based on the API https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.BackendRef
seems like the fix is a small change in gateway-api layer to skip a backend with a
0weightSkip backendRefs with weight set to 0
bug: skip backendRefs with weight set to 0 (#2515)