-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Separate limits scaling between CPU & memory #4113
Separate limits scaling between CPU & memory #4113
Conversation
Welcome @sibucan! |
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.
Thanks & sorry for slow reply.
Please add some tests that cover cases when we expect this to behave differently
return &resource.Quantity{} | ||
} | ||
// originalLimit set but originalRequest not set - K8s will treat the pod as if they were equal | ||
if originalRequest == nil || originalRequest.Value() == 0 { |
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.
Why this is not in GetBoundaryRequestCPU
? I think it should be there.
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.
It should be there, since GetBoundaryRequestCPU
is just the original function, but renamed. Nothing was removed from it, rather a copy of it was created and named GetBoundaryRequestMem
to get the scaled memory values (as opposed to scaled CPU values).
|
||
// GetBoundaryRequestMem returns the boundary (min/max) memory request that can be specified with | ||
// preserving the original limit to request ratio. Returns nil if no boundary exists | ||
func GetBoundaryRequestMem(originalRequest, originalLimit, boundaryLimit, defaultLimit *resource.Quantity) *resource.Quantity { |
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.
GetBoundaryRequestMem
is (and should be) very similar to GetBoundaryRequestCPU
(it looks like the only difference is that CPU operates on milli units and Memory operates on whole values). I'd rather avoid having two very similar pieces of code
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.
That's fair -- I could revert these changes and keep the original function name, and instead add a new input parameter to the function (e.g. "cpu" or "memory") which will determine what scaling function to use. How does that sound?
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.
Sounds good to me
@jbartosik made changes based on feedback & added tests for the changes made in the scaling function, lmk if you find any other issues |
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.
A couple more small changes
vertical-pod-autoscaler/pkg/utils/vpa/limit_and_request_scaling.go
Outdated
Show resolved
Hide resolved
vertical-pod-autoscaler/pkg/utils/vpa/limit_and_request_scaling.go
Outdated
Show resolved
Hide resolved
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.
Thank you. Looks good to me now. Please squash then I'll approve this PR
e9a8ec6
to
538b467
Compare
Commits have been squashed together to a single one. |
@jbartosik I noticed that some tests were failing -- one of the tests failures was a simple change due to how memory resources are now displayed correctly, but the other failure was a bit more complicated to debug and it's related to the rounding logic. It seems that previously, the rounding for memory values worked by taking advantage of the millivalue representation:
However, after these changes, the results just don't round the same way anymore:
This causes some of the tests to fail. I'm not sure how to fix this, since changing the rounding scale only makes the rounded result differ from current tests even more, e.g. using a scale of 1 would make I changed the expected values to reflect the new actuals, but I'm not sure of the implications of doing this. Any advice would be appreciated. |
fd0b01a
to
24b92fe
Compare
I just rebased from the latest master commit to fix the cluster feeder test, if you could run the tests one more time that would be great! :) |
@jbartosik do you have the time to re-review and re-run tests one more time? Just checking in since it's been more than three weeks since our last interaction. Thanks! |
@sibucan I still see two commits. Please squash |
Treating them both the same would cause issues when the ratio between the requests and the limits is a floating-point value, suggesting a millivalue as the limit for memory.
24b92fe
to
c18cf2e
Compare
@jbartosik Hi! I just thought you'd want to re-review that other commit by itself before I squashed commits, but I went ahead and squashed again in the interest of time. |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jbartosik, sibucan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
See the comment I made for issue #3965
When the ratio between the original memory requests/limits on the Deployment is a floating point number instead of an integer, the calculated limit is expressed in millivalues, (https://play.golang.org/p/dR4SaXRBGmB) which is valid for CPU values, but not necessarily for memory values.
The purpose of this PR is to ensure it is expressed as bytes.