Skip to content
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

list vpacheckpoint using vpacheckpoint lister #6419

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yunwang0911
Copy link

What type of PR is this?

What this PR does / why we need it:

Use vpacheckpoint lister instead of vpacheckpoint client when vpa recommender lists vpacheckpoint.

As we all know, query objects from kube-apiservice may increase the stress to kube-apiservice. What's more, vpa recommender might be limited when it lists vpacheckpoint by client. This pr changes the vpa recommender to use lister instead of client.

Which issue(s) this PR fixes:

No

Special notes for your reviewer:

Does this PR introduce a user-facing change?

No.

changes the vpa recommender to use lister instead of client to list vpacheckpoint.

Copy link

linux-foundation-easycla bot commented Jan 4, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jan 4, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @yunwang0911!

It looks like this is your first PR to kubernetes/autoscaler 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/autoscaler has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 4, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 3, 2024
@voelzmo
Copy link
Contributor

voelzmo commented Jul 25, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 25, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 23, 2024
@adrianmoisey
Copy link
Member

@yunwang0911 are you willing to update this with master? I have capacity to review it

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 12, 2024
@yunwang0911 yunwang0911 changed the title list vpacheckpoint from local cache list vpacheckpoint using vpacheckpoint lister Dec 12, 2024
@yunwang0911
Copy link
Author

@adrianmoisey Rebased

vertical-pod-autoscaler/pkg/utils/vpa/api.go Outdated Show resolved Hide resolved
vertical-pod-autoscaler/pkg/utils/vpa/api.go Outdated Show resolved Hide resolved
Since it can relieve apiserver pressure
Beside, it decreases the possibility that vpa recommender is limited by client-go when it accesses the vpacheckpoint

# Conflicts:
#	vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go
#	vertical-pod-autoscaler/pkg/recommender/main.go
@adrianmoisey
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 30, 2024
@yunwang0911
Copy link
Author

@voelzmo @adrianmoisey @kwiesmueller Could you please approve this PR?

@kwiesmueller
Copy link
Member

/assign @raywainman

@adrianmoisey
Copy link
Member

/milestone vertical-pod-autoscaler-1.4.0

Copy link
Contributor

@voelzmo voelzmo left a 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 guess we'll have to do some rebasing between this and #7716 though.

vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1"
vpa_clientset "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned"
vpa_api "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1"
vpa_lister "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1"
controllerfetcher "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/target/controller_fetcher"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to re-order these imports to the lower section, please leave them as-is

@@ -284,11 +285,11 @@ func (feeder *clusterStateFeeder) GarbageCollectCheckpoints() {

for _, namespaceItem := range namespaceList.Items {
namespace := namespaceItem.Name
checkpointList, err := feeder.vpaCheckpointClient.VerticalPodAutoscalerCheckpoints(namespace).List(context.TODO(), metav1.ListOptions{})
checkpointList, err := feeder.vpaCheckpointLister.VerticalPodAutoscalerCheckpoints(namespace).List(labels.Everything())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think now that we have a vpaCheckpointLister inside the cluster_feeder, we no longer need the list of namespaces here.
Instead, we can just list all checkpoints (already filtered by vpaObjectNamespace, if that is set) above like this

checkpointList, err := feeder. vpaCheckpointLister.List(labels.Everything())

And then iterate over those checkpoints and filter them, if they are in a namespace that is in vpaIgnoredNamespaces. Alternatively, we could do the filtering once on the entire list, similar to what is done in filterVPAs

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yunwang0911
Once this PR has been reviewed and has the lgtm label, please ask for approval from raywainman. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -284,11 +285,11 @@ func (feeder *clusterStateFeeder) GarbageCollectCheckpoints() {

for _, namespaceItem := range namespaceList.Items {
namespace := namespaceItem.Name
checkpointList, err := feeder.vpaCheckpointClient.VerticalPodAutoscalerCheckpoints(namespace).List(context.TODO(), metav1.ListOptions{})
checkpointList, err := feeder.vpaCheckpointLister.VerticalPodAutoscalerCheckpoints(namespace).List(labels.Everything())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. You can refer to this: cluster_feeder.go#L330 for an example of how to filter the checkpoints based on the desired namespaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants