-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Ensure CPU and Memory values are properly backfilled in GetContainersResources when VPA only touches one of CPU or Memory #7037
Conversation
…Resources when addAll is set
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: raywainman The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
pod := test.Pod().WithName("pod").AddContainer(tc.container).Get() | ||
resources := GetContainersResources(pod, tc.vpa.Spec.ResourcePolicy, *tc.vpa.Status.Recommendation, nil, true, vpa_api_util.ContainerToAnnotationsMap{}) |
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.
Does it make sense to also add some tests for when addAll
is set to false?
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 initially kept them out because this scenario is implicitly tested with the GetContainersResourcesForPod
testing that is done above this, however we probably shouldn't rely on this implementation detail incase it changes in the future.
Added some tests covering the addAll = false
case. This is much simpler because it will only return the values that VPA changed.
Thanks!
This reverts commit a3f28ed.
Add raywainman as reviewer of VPA
I've made a mess of this PR, will open a new one. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
In the GetContainersResources function there is an
addAll
boolean which is used to ensure that when applying the VPA recommendations, all other resource usage information is still preserved in the final output.For example, when only applying recommendations to a single container in a pod, this would ensure other containers are included in the output.
There is a bug in this code for VPAs that only touch CPU or Memory where it would drop the other resource value.
Which issue(s) this PR fixes:
No issue filed.
Special notes for your reviewer:
Does this PR introduce a user-facing change?
No - this code path (with
addAll = true
is not actually anywhere in this repository. Some Cloud Providers may be relying on this path internally.Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
None