-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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 hpa scaling above max replicas w/ scaleUpLimit #53690
Fix hpa scaling above max replicas w/ scaleUpLimit #53690
Conversation
Hi @mattjmcnaughton. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/assign @DirectXMan12 (because you've already been involved in the issue) :) |
/lgtm |
/ok-to-test |
/retest Review the full test history for this PR. |
@mattjmcnaughton It looks like this doesn't pass gofmt. Can you update the PR? |
/retest Review the full test history for this PR. |
Fix kubernetes#53670 Fix a bug where `desiredReplicas` could be greater than `maxReplicas` if the original value for `desiredReplicas > scaleUpLimit` and `scaleUpLimit > maxReplicas`. Previously, when that happened, we would scale up to `scaleUpLimit`, and then in the next auto-scaling run, scale down to `maxReplicas`. Address this issue and introduce a regression test.
bbf7274
to
75c3877
Compare
Whoops! Fixed and ready for a final look @mwielgus @MaciekPytel Re cherry-picking onto 1.7 and 1.8, is that something I do, or something a bot does, or something the OWNERs do? Thanks for the quick eyes on this :) |
/retest |
There is a script for cherry-picking to particular branch in |
// Ensure that even if the scaleUpLimit is greater | ||
// than the maximum number of replicas, we only | ||
// set the max number of replicas as desired. | ||
if scaleUpLimit > hpa.Spec.MaxReplicas { |
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.
This is basically an exact copy-paste of one of the cases below. Adding ifs checking whether we would trigger condition of a different case if we haven't already triggered the one we're in makes me think switch-case is not the right solution here and we should move to a sequence of ifs instead (perhaps contained in a separate function that can be unittested in isolation).
Especially since we already had a very similar bug caused by interaction of conditions in this switch-case: #48997.
I'm ok with keeping this bugfix as is, but we should revisit this part of hpa, clean it up and make sure it's reasonably unittested to avoid another such issue in future. @mwielgus @DirectXMan12
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.
I've created an issue #53728 to do this.
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MaciekPytel, mattjmcnaughton, mwielgus Associated issue: 53670 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
@mattjmcnaughton: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@mattjmcnaughton can you create cherry-pick PRs for this into 1.7 and 1.8 branches? This is done by just running hack/cherry_pick_pull.sh script. Alternatively I can create them for you. |
Yup, I can create the cherry-pick PRs - I'll do it rn :) |
Commit found in the "release-1.7" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked. |
What this PR does / why we need it:
Fix a bug where
desiredReplicas
could be greater thanmaxReplicas
if the original value for
desiredReplicas > scaleUpLimit
andscaleUpLimit > maxReplicas
. Previously, when that happened, we wouldscale up to
scaleUpLimit
, and then in the next auto-scaling run, scaledown to
maxReplicas
. Address this issue and introduce a regressiontest.
Which issue this PR fixes
fixes #53670
Release note: