fix: reject maxTrafficWeight below 1 - #4924
Open
semx wants to merge 1 commit into
Open
Conversation
The CRD accepts any int32 for maxTrafficWeight, and the value is used as a divisor when replica counts are derived from traffic weights. Setting it to 0 makes checkReplicasAvailable panic with an integer divide by zero, which fails the reconcile for that rollout. Reject it during validation, next to the existing maxTrafficWeight check, so the user gets an InvalidSpec condition instead. Signed-off-by: semx <7532921+semx@users.noreply.github.com>
|
Contributor
Published E2E Test Results 4 files 4 suites 4h 3m 8s ⏱️ For more details on these failures, see this check. Results for commit b46c354. |
Contributor
Published Unit Test Results2 580 tests 2 580 ✅ 3m 26s ⏱️ Results for commit b46c354. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4924 +/- ##
==========================================
- Coverage 85.12% 85.06% -0.06%
==========================================
Files 166 166
Lines 19238 19240 +2
==========================================
- Hits 16376 16367 -9
- Misses 2019 2024 +5
- Partials 843 849 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.



maxTrafficWeightis used as a divisor, but nothing stops it from being zero.The problem
The CRD puts no bound on the field:
Validation checks that each
setWeightis between 0 andmaxTrafficWeight, but never checksmaxTrafficWeightitself. WithmaxTrafficWeight: 0asetWeight: 0step still passes, andcheckReplicasAvailabledivides by it:which panics:
The panic is recovered by the workqueue, but the reconcile for that rollout fails each time it is retried.
The fix
Reject values below 1 during validation, next to the existing
maxTrafficWeightcheck, so the user gets anInvalidSpeccondition explaining the problem.getRolloutValidationErrorsruns before the reconcile touches the traffic weights, so the division is no longer reachable with a zero total weight.Negative values are rejected too — they produce negative replica counts rather than a panic.
Test
Added a case to
TestValidateRolloutStrategyCanarycovering0and-1. It fails without the check and passes with it.