-
Notifications
You must be signed in to change notification settings - Fork 42k
Allow hostname-override arg to be used if specified #69340
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
Allow hostname-override arg to be used if specified #69340
Conversation
d1c4741 to
3f87bd7
Compare
cmd/kube-proxy/app/server.go
Outdated
| ) | ||
|
|
||
| var ( | ||
| hostNameOverride string |
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.
If we decide to proceed with this one-off approach for hostnameOverride, let's make this an unexported field in Options.
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.
cc @mtaufen
cmd/kube-proxy/app/server.go
Outdated
| if err := opts.Complete(); err != nil { | ||
| glog.Fatalf("failed complete: %v", err) | ||
| } | ||
| if err := opts.ProcessArgs(); err != nil { |
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.
Instead of adding a new top-level function to the complete/validate/run flow, I'd recommend renaming ProcessArgs() to processHostnameOverrideFlag() and calling it from within Complete()
cmd/kube-proxy/app/server_test.go
Outdated
|
|
||
| // TestProcessArgs tests processing args | ||
| func TestProcessArgs(t *testing.T) { | ||
|
|
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.
Please remove
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 has been renamed to match the code it is testing.
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.
... the blank line
cmd/kube-proxy/app/server_test.go
Outdated
| testCases := []struct { | ||
| name string | ||
| hostnameArg string | ||
| expHostname string |
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.
exp->expected
cmd/kube-proxy/app/server.go
Outdated
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.
gofmt
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.
also: if err := ...; err != nil {
cmd/kube-proxy/app/server.go
Outdated
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.
Revert?
5102ffa to
7b9e797
Compare
|
@ncdc I addressed your comments, thanks! |
cmd/kube-proxy/app/server.go
Outdated
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.
I would call this hostnameOverride
cmd/kube-proxy/app/server.go
Outdated
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.
How about something like
hostnameOverride, if set from the command line flag, takes precedence over the `HostnameOverride` value from the config file
cmd/kube-proxy/app/server.go
Outdated
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.
argument -> flag
cmd/kube-proxy/app/server_test.go
Outdated
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.
Is this needed?
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.
no not needed, removing
cmd/kube-proxy/app/server_test.go
Outdated
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.
hostnameArg -> hostnameOverrideFlag
cmd/kube-proxy/app/server_test.go
Outdated
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.
argument -> flag
cmd/kube-proxy/app/server_test.go
Outdated
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.
Use a go subtest:
t.Run(tc.name, func(t *testing.T) {
// body of test case
}
cmd/kube-proxy/app/server_test.go
Outdated
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.
When you switch to using a subtest, you can remove the initial %s for tc.name
cmd/kube-proxy/app/server_test.go
Outdated
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.
When you switch to using a subtest, you can remove the initial %s for tc.name
|
/ok-to-test /cc @kubernetes/sig-network-pr-reviews |
Signed-off-by: Steve Sloka <[email protected]>
7b9e797 to
5834f94
Compare
|
/retest |
|
@kubernetes/sig-network-pr-reviews - re-ping! |
|
|
||
| // processHostnameOverrideFlag processes hostname-override flag | ||
| func (o *Options) processHostnameOverrideFlag() error { | ||
| // Check if hostname-override flag is set and use value since configFile always overrides |
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.
I thought the flag would always override - the flag reads into the config struct..
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.
@thockin I did kube-proxy first, as a POC, and it got merged well before all the docs/discussions on the proper way to do things going forward. I didn't realize that there would be a need for per-instance configuration settings as well as those that are shared across all instances. The way kube-proxy specifically works, today, is that it's completely either-or. Either you use a config file, or you use flags. Flags do not override the config file.
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.
blech
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: stevesloka, thockin 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 |
|
You may find that this becomes a general problem. |
|
(fwiw, the |
What this PR does / why we need it:
Currently
kube-proxyloads configuration from a config file. There are cases where the hostname needs to be overridden (See: kubernetes/kubeadm#857).There is a flag that allows the hostname to be overridden (
hostname-override), but when the config file is loaded, if this arg is set, it's overridden by whatever the config file contains making the argument ignored if it was set.This PR checks for this argument and uses it if it is passed to
kube-proxy.Which issue(s) this PR fixes:
Fixes #57518
Fixes kubernetes/kubeadm#857
Special notes for your reviewer:
Release note:
// @timothysc
Signed-off-by: Steve Sloka [email protected]