Skip to content

Refactor recommender to follow NewXXXController pattern#9462

Open
adrianmoisey wants to merge 2 commits intokubernetes:masterfrom
adrianmoisey:adrian-controller-model
Open

Refactor recommender to follow NewXXXController pattern#9462
adrianmoisey wants to merge 2 commits intokubernetes:masterfrom
adrianmoisey:adrian-controller-model

Conversation

@adrianmoisey
Copy link
Copy Markdown
Member

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This is my third attempt at #8934

This PR replaces #9156

I spent some time looking at k/k's controllers, and tried to copy that pattern. This PR isn't perfect, I think in theory any informer should be created outside of NewRecommenderController() and passed in. For VPA that's quite a lot of informers, so I tried to keep this slim.
I also tried to keep this change minimal, I plan to make more follow up PRs for the other 2 VPA components, and more tests.
I also decided against envtest, since I was looking at k/k patterns.

I also only made 1 test as an example, I plan to fill those out later.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

AI assisted

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/needs-area labels Apr 8, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianmoisey

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. area/vertical-pod-autoscaler labels Apr 8, 2026
@k8s-ci-robot k8s-ci-robot requested review from feiskyer and voelzmo April 8, 2026 11:02
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/needs-area labels Apr 8, 2026
@adrianmoisey adrianmoisey force-pushed the adrian-controller-model branch 2 times, most recently from 9f62c17 to 3c00d17 Compare April 8, 2026 15:39
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This doesn't run under CI for now, that needs to be hooked up in the future.

@adrianmoisey adrianmoisey force-pushed the adrian-controller-model branch from 3c00d17 to 7f1f64a Compare April 8, 2026 15:39
Copy link
Copy Markdown
Member

@maxcao13 maxcao13 left a comment

Choose a reason for hiding this comment

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

general question for now, I will look at the code in more detail later:

I assume if we are trying to emulate kubernetes and we still have the plan of eventually making VPA components business loops event-driven, then we will eventually adopt their pattern of controllers and reconcilers, instead of something like controller-runtime + envtest.

@adrianmoisey
Copy link
Copy Markdown
Member Author

general question for now, I will look at the code in more detail later:

I assume if we are trying to emulate kubernetes and we still have the plan of eventually making VPA components business loops event-driven, then we will eventually adopt their pattern of controllers and reconcilers, instead of something like controller-runtime + envtest.

Long term, I don't have a strong opinion either way. That's possibly something we should figure out. I don't have any controller-runtime experience.

The reason I went this direction for this PR was that I spent time familiarising myself with the patterns in k/k, and the path to getting this done in VPA became more obvious (ie: this PR).

What I'm not sure about is if this PR moves us away from controller-runtime + envtest in the future, or potentially towards that.

/hold
(Holding to ensure we get enough review on this before merging)

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 8, 2026
@adrianmoisey
Copy link
Copy Markdown
Member Author

/cc iamzili
/cc omerap12

@k8s-ci-robot k8s-ci-robot requested review from iamzili and omerap12 April 8, 2026 16:53
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 9, 2026
And include a script to run integration tests only.
It requires etcd to be installed.
@adrianmoisey adrianmoisey force-pushed the adrian-controller-model branch from 7f1f64a to 085711e Compare April 9, 2026 11:12
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants