-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: Config file overrides apply to some fields but not other #2705
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
fix: Config file overrides apply to some fields but not other #2705
Conversation
/assign @rexagod |
Hi @rexagod - You have been assigned as a reviewer. Could you please review this PR? Thanks! |
@dgrisonnet @CatherineF-dev - Gentle ping, pls take a look at the pr and provide your review, thanks! |
@CatherineF-dev - Added tests as per your feedback, pls take a look. Thanks! |
pkg/app/server.go
Outdated
@@ -378,6 +379,45 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { | |||
return nil | |||
} | |||
|
|||
func configureResourcesAndMetrics(opts *options.Options, configFile []byte) *options.Options { | |||
// If the config file is set, we will overwrite the opts with the config file. | |||
// This is only needed for types that are a slice of structs because the default behaviour of yaml.Unmarshal is to append instead of overwrite |
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.
// This is only needed for types that are a slice of structs because the default behaviour of yaml.Unmarshal is to append instead of overwrite | |
func configureResourcesAndMetrics(opts *options.Options, configFile []byte) *options.Options { | |
// If the config file is set, we will overwrite the opts with the config file. | |
// This is only needed for maps because the default behaviour of yaml.Unmarshal is to append keys (and overwrite any conflicting ones). |
I'd suggest adding a comment about the config file taking precedence over options in the flag description.
Also, I believe we need to do this for AnnotationsAllowList
and LabelsAllowList
as well?
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.
Good catch. Added this too. @rexagod - please take a look
@rashmichandrashekar this seems to be running into some CI failures. |
Thanks @richabanker. Could you pls retrigger the runs? |
Triggered the CI run /ok-to-test for others to review: |
Pinging other reviewers - @dgrisonnet @CatherineF-dev - This PR is waiting on additional reviewers. Could you pls take a look? Thanks! |
I believe this is remaining here? |
Thanks! added |
@richabanker and I find standard practice is using command-line arguments to override configuration file. If so, is your project blocked by this? Could you find other ways? |
@CatherineF-dev - The current behavior is that the config file overrides the cli args. This PR is making it consistent for all params. Yes, if the change is to break this behavior, it is blocking. |
/ok-to-test |
/lgtm Re-iterating from the sig meeting, since this fix makes the behavior of overriding CLI flags with config file consistent for slice params, makes sense to me to have this fix merged now. While this is opposite to the pattern we have for the main K8s components, but this was a choice made early on, which will require a separate dedicated discussion/enhancement if we want to adopt that for KSM due to the breaking nature of the change. |
/hold |
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.
Could you please squash the commits here as well?
/ok-to-test |
1 similar comment
/ok-to-test |
9ad6c65
to
9211476
Compare
Done |
@rexagod - Addressed all comments. pls take a look |
/lgtm on using config file to override command flags. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CatherineF-dev, mrueg, rashmichandrashekar, rexagod, richabanker The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
Fixes bug where some option values are overriden with config file but not others.
Provides optional behavior for backward compatiblity
How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)
Does not change cardinality
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #2704