Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API Gateway] HTTPRoutes with weights that don't divide evenly into 10000 #16455

Closed
andrewstucki opened this issue Feb 28, 2023 · 0 comments · Fixed by #16531
Closed

[API Gateway] HTTPRoutes with weights that don't divide evenly into 10000 #16455

andrewstucki opened this issue Feb 28, 2023 · 0 comments · Fixed by #16531
Labels
theme/api-gw Track API gateway work

Comments

@andrewstucki
Copy link
Contributor

andrewstucki commented Feb 28, 2023

Overview of the Issue

Under the hood we do calculations based on the passed in weight for HTTPRoute services to normalize them into a percentage, which the virtual service splitters end up translating internally to envoy xDS, scaled to its required total weight of 10000 per-route.

weightPercentage := float32(service.Weight) / float32(totalWeight)
split := structs.ServiceSplit{
RequestHeaders: modifier,
Weight: weightPercentage * 100,
}

When we provide weights that, when summed, don't divide evenly into 10000, we get errors due to errors in float rounding and envoy complains that it requires a total weight of 10000 when doing weighted load-balancing.

Reproduction Steps

Create and attach an HTTPRoute with weights for a set of services that don't divide evenly into 10000, such as:

Rules = [
  {
    Services = [
      {
        Name = "service-one"
        Weight = 2
      },
      {
        Name = "service-two"
        Weight = 1
      }
    ]
  }
]

Here's a simple go snippet of the rounding behavior we're hitting. We should ensure that we handle rounding errors by doing something like adding whatever offset necessary to the highest weighted service in order to normalize all weight percentages to exactly equal 100 (or 10000 when converted to xDS).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/api-gw Track API gateway work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant