-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
kube-controller-manager: fix missing global flags for --help #70216
kube-controller-manager: fix missing global flags for --help #70216
Conversation
Hi @imjching. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: imjching If they are not already assigned, you can assign the PR to them by writing 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 |
cc @logicalhan |
/hold #68054 is trying to add in |
/milestone v1.13 |
/ok-to-test |
@dims Got it! I'll rebase and update this patch together with the remaining patches tomorrow. 😄 |
c5e1146
to
657a09d
Compare
/hold cancel |
/test pull-kubernetes-integration |
/lgtm |
"github.com/spf13/pflag" | ||
|
||
// ensure libs have a chance to globally register their flags | ||
_ "k8s.io/cloud-provider" |
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 don't think k8s.io/cloud-provider
registers any flags unless I'm missing something.
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 think what you really want is k8s.io/kubernetes/pkg/cloudprovider/providers
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.
Yes, you're right. This is the flag that I am looking for:
flag.Var(&lbSrcRngsFlag, "cloud-provider-gce-lb-src-cidrs", "CIDRs opened in GCE firewall for LB traffic proxy & health checks") |
I remember using k8s.io/kubernetes/pkg/cloudprovider/providers
back then, but there was a build error. I just updated the path and hopefully it's all good now.
FYI code freeze is today at 5pm PST - this should ideally make it before the deadline since it looks ready. @sttts @andrewsykim @imjching |
Signed-off-by: Jay Lim <jay@imjching.com>
657a09d
to
9e57c62
Compare
global := flag.CommandLine | ||
local := pflag.NewFlagSet(os.Args[0], pflag.ExitOnError) | ||
|
||
register(global, local, "cloud-provider-gce-lb-src-cidrs") |
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 don't love that this is here, we shouldn't leak provider flags like this but I get that it's not so easy to work around global flags. @sttts @stewart-yu any thoughts on this?
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.
Hmm, I agree. I'm not too sure if there's a better way to do this. At the moment, we're doing something similar for kubelet
as well:
kubernetes/cmd/kubelet/app/options/globalflags.go
Lines 82 to 92 in 7ff49c9
func addCredentialProviderFlags(fs *pflag.FlagSet) { | |
// lookup flags in global flag set and re-register the values with our flagset | |
global := pflag.CommandLine | |
local := pflag.NewFlagSet(os.Args[0], pflag.ExitOnError) | |
// TODO(#58034): This is not a static file, so it's not quite as straightforward as --google-json-key. | |
// We need to figure out how ACR users can dynamically provide pull credentials before we can deprecate this. | |
pflagRegister(global, local, "azure-container-registry-config") | |
fs.AddFlagSet(local) | |
} |
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 think it's OK for now, and we should find out more elegant way later. @andrewsykim
/test pull-kubernetes-e2e-gce |
/priority critical-urgent Let's get this in and revisit any changes for 1.14 ( cc @andrewsykim ) |
@imjching can you push the add file in https://github.com/kubernetes/kubernetes/tree/master/cmd/controller-manager/app/options directory, so we can reuse it both KCM and CCM |
// register adds a flag to local that targets the Value associated with the Flag named globalName in global | ||
func register(global *flag.FlagSet, local *pflag.FlagSet, globalName string) { | ||
if f := global.Lookup(globalName); f != nil { | ||
local.AddGoFlag(f) |
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.
Why a different logic as in a77652e#diff-2fd8f885c4e1d904b7d678e5991aade4R68 ?
global := flag.CommandLine | ||
local := pflag.NewFlagSet(os.Args[0], pflag.ExitOnError) | ||
|
||
register(global, local, "cloud-provider-gce-lb-src-cidrs") |
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 do we know not flag is forgotten? We need a test or a runtime error (or even panic?) for that.
@sttts do you think this PR is good to be approved for 1.13? If so can you plz approve it to enable merge? |
What type of PR is this?
/kind bug
What this PR does / why we need it: In #67362, we introduced logical sections for the
--help
output in thekube-controller-manager
binary. It seems like it does not consider global flags that were registered through theflag
package. This PR fixes that issue. We will output glog related and version flags in the "global" section, and everything else in the "generic" section.Which issue(s) this PR fixes:
See #70145.
Special notes for your reviewer: The original PR is in #70164. The plan to is to break it down into individual PRs.
Does this PR introduce a user-facing change?:
/sig cli
/cc @stewart-yu @andrewsykim @dims
/assign @deads2k