Skip to content

VPA: Refactor how flags are set#9195

Open
adrianmoisey wants to merge 6 commits intokubernetes:masterfrom
adrianmoisey:adrian-flags
Open

VPA: Refactor how flags are set#9195
adrianmoisey wants to merge 6 commits intokubernetes:masterfrom
adrianmoisey:adrian-flags

Conversation

@adrianmoisey
Copy link
Member

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This is step 1 of #9156

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

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


/hold

I only plan for this to be merged after the VPA 1.6 release

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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 size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/vertical-pod-autoscaler labels Feb 7, 2026
@k8s-ci-robot
Copy link
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. and removed do-not-merge/needs-area labels Feb 7, 2026
@adrianmoisey
Copy link
Member Author

Oh, some flags live in vertical-pod-autoscaler/pkg/updater/priority/update_priority_calculator.go that I still need to move

Copy link
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.

Thanks for this! Works fine for me locally, just one comment.

scaleCacheEntryJitterFactor float64 = 1.
)

var config *updater_config.UpdaterConfig
Copy link
Member

Choose a reason for hiding this comment

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

We have a global (file?) scoped variable for the config now instead of the individual flags but now it includes commonFlags, but we still also pass commonFlags to run: https://github.com/kubernetes/autoscaler/pull/9195/changes#diff-a64cbe814d071ca8df41b2890583bd9e92c3fb39fbbe57e17f013e434b2d108aR150. I don't think we need to pass commonFlag anymore, or maybe there's some other way to not duplicate?

This happens in all 3 components I believe.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, good question.
That's a transition to get the flags moved out of main. Once the logic for each component is changed to allow for integration tests, all configs will be passed in and the config shouldn't be global.

See https://github.com/kubernetes/autoscaler/pull/9156/changes#diff-bc201689c0c988297d4f93cf844937aa4f4755bfdc5bc912746148eaeed3bb64R48
And https://github.com/kubernetes/autoscaler/pull/9156/changes#diff-bc201689c0c988297d4f93cf844937aa4f4755bfdc5bc912746148eaeed3bb64R55

I made the config global just to keep the change as light as possible in this PR, with the plans to move things around later.

@adrianmoisey
Copy link
Member Author

Thanks for this! Works fine for me locally, just one comment.

Thanks for the review!
Unfortunately I have more changes to push, I found a BUNCH of flags that I had forgotten about, in various other files.
I'll keep those changes as new commits to help with the review.

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 14, 2026
@adrianmoisey
Copy link
Member Author

Unfortunately I have more changes to push, I found a BUNCH of flags that I had forgotten about, in various other files.
I'll keep those changes as new commits to help with the review.

Pushed, it's a little more difficult to review, but kept to a single commit

Copy link
Member

@omerap12 omerap12 left a comment

Choose a reason for hiding this comment

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

Some comments from me.

Comment on lines 35 to 38
// CertsConfig holds configuration related to TLS certificates
type CertsConfig struct {
ClientCaFile, TlsCertFile, TlsPrivateKey *string
Reload *bool
Copy link
Member

Choose a reason for hiding this comment

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

I can't find a place where use this. maybe we should remove it instead?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed

// ValidateAdmissionControllerConfig performs validation of the admission-controller flags
func ValidateAdmissionControllerConfig(config *AdmissionControllerConfig) {
common.ValidateCommonConfig(config.CommonFlags)
}
Copy link
Member

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 you to use ValidateAdmissionControllerConfig inside InitAdmissionControllerFlags function and then return error if ValidateCommonConfig returns error?
Then we won't need https://github.com/kubernetes/autoscaler/pull/9195/changes#diff-0d60ce44b7823f02b8363916a2843a184b7f4cb4f1d75ab45d3954af4f25def4R68.
My concern is that someone could use InitAdmissionControllerFlags and will forget to validate.

Copy link
Member

Choose a reason for hiding this comment

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

This is true for all of the components

Copy link
Member Author

Choose a reason for hiding this comment

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

Moving this required a bit of other work related to the kubernetes flag we're using, I hope the end result makes sense

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 14, 2026
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 14, 2026
Configure a struct that can be passed around, and populate that with
CLI flags
I had missed these on previous commits since they aren't in main.go
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 16, 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.

4 participants