Skip to content
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

Conversation

imjching
Copy link
Contributor

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 the kube-controller-manager binary. It seems like it does not consider global flags that were registered through the flag 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?:

Fix missing flags in kube-controller-manager --help.

/sig cli
/cc @stewart-yu @andrewsykim @dims
/assign @deads2k

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 25, 2018
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Oct 25, 2018
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 25, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: imjching
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: deads2k

If they are not already assigned, you can assign the PR to them by writing /assign @deads2k in a comment when ready.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jennybuckley
Copy link

cc @logicalhan

@imjching
Copy link
Contributor Author

/hold

#68054 is trying to add in globalflags.go into apiserver/pkg/util/flag/. Will wait until that is merged in so that we could rebase and use methods from there.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 26, 2018
@dims
Copy link
Member

dims commented Nov 11, 2018

/milestone v1.13

@k8s-ci-robot k8s-ci-robot added this to the v1.13 milestone Nov 11, 2018
@dims
Copy link
Member

dims commented Nov 12, 2018

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 12, 2018
@dims
Copy link
Member

dims commented Nov 12, 2018

@imjching can you please update this PR since #68054 has merged?

@imjching
Copy link
Contributor Author

@dims Got it! I'll rebase and update this patch together with the remaining patches tomorrow. 😄

@imjching imjching force-pushed the 70145-fix-global-flags-kube-controller-manager branch from c5e1146 to 657a09d Compare November 15, 2018 04:38
@imjching
Copy link
Contributor Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 15, 2018
@imjching
Copy link
Contributor Author

/test pull-kubernetes-integration

@dims
Copy link
Member

dims commented Nov 15, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 15, 2018
"github.com/spf13/pflag"

// ensure libs have a chance to globally register their flags
_ "k8s.io/cloud-provider"
Copy link
Member

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.

Copy link
Member

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

Copy link
Contributor Author

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.

@nikopen
Copy link
Contributor

nikopen commented Nov 16, 2018

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>
@imjching imjching force-pushed the 70145-fix-global-flags-kube-controller-manager branch from 657a09d to 9e57c62 Compare November 16, 2018 19:11
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 16, 2018
global := flag.CommandLine
local := pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)

register(global, local, "cloud-provider-gce-lb-src-cidrs")
Copy link
Member

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?

Copy link
Contributor Author

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:

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)
}

Copy link
Contributor

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

@imjching
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce

@dims
Copy link
Member

dims commented Nov 19, 2018

/priority critical-urgent
/lgtm

Let's get this in and revisit any changes for 1.14 ( cc @andrewsykim )

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. labels Nov 19, 2018
@stewart-yu
Copy link
Contributor

@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)
Copy link
Contributor

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")
Copy link
Contributor

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.

@AishSundar
Copy link
Contributor

@sttts do you think this PR is good to be approved for 1.13? If so can you plz approve it to enable merge?

@imjching imjching closed this Nov 21, 2018
@imjching imjching deleted the 70145-fix-global-flags-kube-controller-manager branch November 21, 2018 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants