Skip to content

Weighted Backend couldn't set to 0 #2495

Closed

Description

@ardikabs

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:

  1. Backend A currently serving production traffic. Set the weight to 100.
  2. Preparing backend B for canary deployment. Set the weight to 0.
  3. 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:

  1. Having 2 different backends on HTTPRoute.
  2. One backend set the weight to 100, the other to 0.
  3. You will see error logged by Envoy Gateway like above.
  4. 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"}

Activity

  1. ardikabs commented on Jan 24, 2024

    @ardikabs
    ContributorAuthor

    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.

  2. arkodg commented on Jan 24, 2024

    @arkodg
    Contributor

    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 0 weight

  3. added
    kind/bug
    area/translator
    and removed on Jan 24, 2024
  4. added
    good first issue
    help wanted
    on Jan 24, 2024
  5. added this to the v1.0.0-rc1 milestone on Jan 24, 2024
  6. self-assigned this
    on Jan 27, 2024
  7. removed
    good first issue
    help wanted
    on Jan 27, 2024
  8. added a commit that references this issue on Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/translatorkind/bugroad-to-ga

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions