-
Notifications
You must be signed in to change notification settings - Fork 880
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
fix: Set Canary Strategy default maxUnavailable to 25% #981
fix: Set Canary Strategy default maxUnavailable to 25% #981
Conversation
Signed-off-by: khhirani <[email protected]>
Signed-off-by: khhirani <[email protected]>
adbd69e
to
0d0ee20
Compare
Codecov Report
@@ Coverage Diff @@
## master #981 +/- ##
=======================================
Coverage 81.36% 81.36%
=======================================
Files 100 100
Lines 8844 8844
=======================================
Hits 7196 7196
Misses 1180 1180
Partials 468 468
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Can you update both the documentation and the types.go to reflect this?
DefaultMaxSurge = "25" | ||
// DefaultMaxUnavailable default number for the max number of unavailable pods during a rollout | ||
DefaultMaxUnavailable = 0 | ||
DefaultMaxUnavailable = "25" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why this is 25
and not 25%
. Can you verify that we aren't defaulting max unavailable to 25 pods instead of 25% of pods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code which resolves both MaxSurge and MaxUnavailable uses the method intstrutil.GetValueFromIntOrPercent
. I confirmed that it works with some manual tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks for confirming. I see that GetValueFromIntOrPercent
interprets all string values as percentages and not integer values, even if the value is missing a %
character:
func GetValueFromIntOrPercent(intOrPercent *IntOrString, total int, roundUp bool) (int, error) {
if intOrPercent == nil {
return 0, errors.New("nil value for IntOrString")
}
value, isPercent, err := getIntOrPercentValue(intOrPercent)
if err != nil {
return 0, fmt.Errorf("invalid value for IntOrString: %v", err)
}
if isPercent {
if roundUp {
value = int(math.Ceil(float64(value) * (float64(total)) / 100))
} else {
value = int(math.Floor(float64(value) * (float64(total)) / 100))
}
}
return value, nil
}
func getIntOrPercentValue(intOrStr *IntOrString) (int, bool, error) {
switch intOrStr.Type {
case Int:
return intOrStr.IntValue(), false, nil
case String:
s := strings.Replace(intOrStr.StrVal, "%", "", -1)
v, err := strconv.Atoi(s)
if err != nil {
return 0, false, fmt.Errorf("invalid value %q: %v", intOrStr.StrVal, err)
}
return int(v), true, nil
}
return 0, false, fmt.Errorf("invalid type: neither int nor percentage")
}
Signed-off-by: khhirani <[email protected]>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Closes #938
Signed-off-by: khhirani [email protected]