VPA: Refactor how flags are set#9195
Conversation
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Oh, some flags live in |
maxcao13
left a comment
There was a problem hiding this comment.
Thanks for this! Works fine for me locally, just one comment.
| scaleCacheEntryJitterFactor float64 = 1. | ||
| ) | ||
|
|
||
| var config *updater_config.UpdaterConfig |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Thanks for the review! |
Pushed, it's a little more difficult to review, but kept to a single commit |
c5684a7 to
40b1605
Compare
| // CertsConfig holds configuration related to TLS certificates | ||
| type CertsConfig struct { | ||
| ClientCaFile, TlsCertFile, TlsPrivateKey *string | ||
| Reload *bool |
There was a problem hiding this comment.
I can't find a place where use this. maybe we should remove it instead?
There was a problem hiding this comment.
I do see where are using: https://github.com/kubernetes/autoscaler/pull/9195/changes#diff-1d9e38171029851f3ff7fab43babd31245cdd3a21201ad79e42a6dd1596ae5dcR27 instead.
| // ValidateAdmissionControllerConfig performs validation of the admission-controller flags | ||
| func ValidateAdmissionControllerConfig(config *AdmissionControllerConfig) { | ||
| common.ValidateCommonConfig(config.CommonFlags) | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This is true for all of the components
There was a problem hiding this comment.
Moving this required a bit of other work related to the kubernetes flag we're using, I hope the end result makes sense
c0bc7ca to
cee795b
Compare
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
cee795b to
de98f82
Compare
de98f82 to
1d1521e
Compare
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?
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