xds/clusterimpl: fix uint32 overflow computing EDS drop ratio#9257
Open
nvxbug wants to merge 2 commits into
Open
xds/clusterimpl: fix uint32 overflow computing EDS drop ratio#9257nvxbug wants to merge 2 commits into
nvxbug wants to merge 2 commits into
Conversation
The EDS drop_overload numerator comes from the control plane and can be as large as a million (a 100% drop). Scaling it with Numerator * million / Denominator in uint32 overflows once the numerator reaches 4295 with the million denominator, so a 0.43% or larger drop collapses toward zero and a fraction above 100% wraps past a million. Do the multiply in uint64 and cap the ratio at a million.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9257 +/- ##
==========================================
- Coverage 83.23% 83.10% -0.13%
==========================================
Files 421 422 +1
Lines 34086 34833 +747
==========================================
+ Hits 28370 28948 +578
- Misses 4281 4394 +113
- Partials 1435 1491 +56
🚀 New features to boost your workflow:
|
easwars
reviewed
Jul 24, 2026
easwars
approved these changes
Jul 24, 2026
Contributor
|
Moving to @mbissa for second set of eyes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
handleClusterConfigLocked turns each EDS drop_overload into a per-million rate with
Numerator * million / Denominatorin uint32. The numerator comes from the control plane and reaches a million for a 100% drop, so with the million denominator the product overflows a uint32 once the numerator hits 4295 (a 0.43% drop), and the rate then collapses toward zero: a 50% drop computes to 0.18% and a 100% drop to 0.36%. A fraction above 100% instead landsRequestsPerMillionabove a million, which underflowsmillion - RequestsPerMillionin newDropper.Move the computation into
dropRequestsPerMillion, which multiplies in uint64 and caps the ratio at a million. Keeping the clamp next to the arithmetic that builds DropConfig leaves the raw numerator and denominator on the parsed resource and applies drops at the configured rate.RELEASE NOTES: