-
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
Feat: improve VPA filtering and checkpoint garbage collection #7716
base: master
Are you sure you want to change the base?
Conversation
@omerap12: The label(s) In response to this:
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-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: omerap12 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 |
/kind feature |
I'm not sure if this is a good idea, but what about updating the flags: autoscaler/vertical-pod-autoscaler/common/flags.go Lines 45 to 46 in b8719d3
|
90cb7a6
to
85370c3
Compare
sounds good |
Signed-off-by: Omer Aplatony <[email protected]>
1e1fc7a
to
8117b14
Compare
/lgtm Thanks! If you're up for it, an e2e test testing the flag would be cool, but I know we have an item in the backlog for that already. |
Signed-off-by: Omer Aplatony <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
Had to rebase so pinging again @adrianmoisey |
/lgtm |
/milestone vertical-pod-autoscaler-1.4.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.
Thanks for the PR, I have some comments where code could be a bit simpler.
vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go
Outdated
Show resolved
Hide resolved
return feeder.vpaObjectNamespace == "" && len(feeder.ignoredNamespaces) == 0 | ||
} | ||
|
||
func (feeder *clusterStateFeeder) cleanupCheckpointsForNamespace(namespace string, allVPAKeys map[model.VpaID]bool) { |
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.
We can make this function return err
and have the caller handle it. This way, you can also simplify the if-else and the error messages, as they don't need to contain the context that this happened inside the garbage collection function. Adding context for the checkpoint listing with e.g. errors.Wrapf
could still be useful, though.
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.
Added in 86eb551
@@ -354,7 +382,7 @@ func filterVPAs(feeder *clusterStateFeeder, allVpaCRDs []*vpa_types.VerticalPodA | |||
} | |||
} | |||
|
|||
if slices.Contains(feeder.ignoredNamespaces, vpaCRD.ObjectMeta.Namespace) { | |||
if !feeder.shouldCleanupNamespace(vpaCRD.ObjectMeta.Namespace) { |
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.
If we're re-using shouldCleanupNamespace
here, I think we should rename it. Currently, its name is tied pretty much to the garbage collection use-case. Maybe it is rather something like shouldIgnoreNamespace
?
On the other hand, we already initialize the vpaLister
with a single namespace if vpaObjectNamespace
is set:
VpaLister: vpa_api_util.NewVpasLister(vpa_clientset.NewForConfigOrDie(config), make(chan struct{}), commonFlag.VpaObjectNamespace), |
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 suppose we can keep using slices.Contains
as it was, but personally, I’m not a fan of duplicated code (since shouldCleanupNamespace
does the same thing).
Do you have a preference? Should we rename the function, or are we okay with some duplication?
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'm fine with renaming the method and reduce duplication. We could also re-use the same method then for filtering the VPACheckpoints returned by the lister introduced in #6419
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.
no problem
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.
Added in 694cce8
vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Omer Aplatony <[email protected]>
New changes are detected. LGTM label has been removed. |
Signed-off-by: Omer Aplatony <[email protected]>
Signed-off-by: Omer Aplatony <[email protected]>
13fb008
to
694cce8
Compare
What type of PR is this?
/kind feature
What this PR does / why we need it:
Currently, the recommender's garbage collection for checkpoints iterates through all namespaces in the cluster, ignoring the
vpaObjectNamespace
andignoredNamespaces
flags. In large-scale clusters, this can lead to performance issues. This PR addresses the problem by ensuring that the garbage collection logic respects the specified flags.Which issue(s) this PR fixes:
Fixes #7697
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: