-
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
vpa-admission-controller: Improve finding the matching VPA for Pod #7010
vpa-admission-controller: Improve finding the matching VPA for Pod #7010
Conversation
Skipping CI for Draft Pull Request. |
9fe3a2b
to
4bd7ae0
Compare
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 for opening the PR! Just one small comment on my side.
vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/matcher.go
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.
Thanks for adding the logs, just some very minor nits.
vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/matcher.go
Outdated
Show resolved
Hide resolved
controlling = vpaWithSelector | ||
controllingVpa = controlling.Vpa | ||
} | ||
} | ||
return controlling | ||
} | ||
|
||
// FindParentControllerForPod returns the parent controller (topmost well-known or scalable controller) for the given Pod. | ||
func FindParentControllerForPod(pod *core.Pod, ctrlFetcher controllerfetcher.ControllerFetcher) (*controllerfetcher.ControllerKeyWithAPIVersion, error) { |
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.
Can a test be written for this function?
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 added unit test in dcbd716.
I am sorry for the delay. I got stuck with other high priority tasks. I will get back to the PR review and address it next week. |
72ecc2b
to
041de8e
Compare
@adrianmoisey @plkokanov @voelzmo I rebased the PR and address review comments! PTAL. |
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 on my side
I've had a look and I'm also generally happy with it |
I gave this a test, seems to work. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ialidzhikov, kwiesmueller, plkokanov 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 |
What type of PR is this?
/kind bug
What this PR does / why we need it:
As outlined in #6925, right now the logic in the vpa-admission-controller to find the matching VPA for a Pod is expensive/ineffective. In a summary, no matter the given Pod is scaled by VPA or not, the vpa-admission-controller gets all VPAs in the namespace and fetches the selector for every VPA. Fetching the selector for a VPA is an expensive operation when the VPA's targetRef is a custom resource. For such cases, the
/scale
subresource is being fetched. Note that the usedselectorFetcher
does not have a cache client-side and it always does a GET request for the/scale
subresource:autoscaler/vertical-pod-autoscaler/pkg/target/fetcher.go
Line 130 in c79bdaf
This PR improves the effectiveness of the operations by using the following steps.
/scale
subresource when the targetRef is a CR) only for VPAs which targetRef is matching the parent controllerIn this way the selector would be fetched only for VPAs that match the Pod's parent controller. Previously it was fetched always for all VPAs in the namespace.
In
GetControllingVPAForPod
func it was always fetching the parent controller for a Pod, hence we are not introducing a change by fetching always the Pod's parent controller at the beginning of theGetMatchingVPA
func.Which issue(s) this PR fixes:
N/A
but a result of the following issues #6925, #6884
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: