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

kubeadm: Make sure --config can be mixed with --skip-* flags #49498

Merged

Conversation

luxas
Copy link
Member

@luxas luxas commented Jul 24, 2017

What this PR does / why we need it:

fixes: kubernetes/kubeadm#352

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:
Should be a cherrypick candidate

Release note:

kubeadm: Fixes a small bug where `--config` and `--skip-*` flags couldn't be passed at the same time in validation.

@kubernetes/sig-cluster-lifecycle-pr-reviews @ericchiang @wojtek-t

@k8s-ci-robot k8s-ci-robot added the sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. label Jul 24, 2017
@luxas
Copy link
Member Author

luxas commented Jul 24, 2017

cc @mattmoyer

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 24, 2017
@luxas luxas added the kind/bug Categorizes issue or PR as related to a bug. label Jul 24, 2017
@luxas luxas added this to the v1.7 milestone Jul 24, 2017
@k8s-github-robot k8s-github-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jul 24, 2017
Copy link
Member

@timothysc timothysc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, the code is not super friendly to read. I would prefer to output the flags that were bad.

return fmt.Errorf("can not mix '--config' with other arguments")
if flag.Changed("config") {
numFlagsAllowedToChange := 1
flagsAllowedToChangeWithConfig := []string{"skip-preflight-checks", "skip-token-print"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just check to see if the flags are anything other then these two and output an error indicating the flags they specified?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want Flagset.Visit https://godoc.org/github.com/spf13/pflag#FlagSet.Visit

mixedFlags := []string{}
flag.Visit(func(f *pflag.Flag) {
    if f.Name == "config" || strings.HasPrefix(f.Name, "skip-") {
        // "skip=*" flags can be set with --config
        return
    }
    mixedFlags = append(mixedFlags, f.Name)
})

@luxas luxas force-pushed the kubeadm_fix_config_validation branch from a96b60d to aa46947 Compare July 24, 2017 19:21
@luxas
Copy link
Member Author

luxas commented Jul 24, 2017

/retest

Copy link
Member

@timothysc timothysc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm - thx for the change, much easier to read.

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: luxas, timothysc

Associated issue: 352

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@luxas
Copy link
Member Author

luxas commented Jul 24, 2017

/retest

@luxas luxas added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 24, 2017
@luxas
Copy link
Member Author

luxas commented Jul 25, 2017

/retest

@wojtek-t wojtek-t added the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Jul 25, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 49498, 49192)

@k8s-github-robot k8s-github-robot merged commit c31a137 into kubernetes:master Jul 25, 2017
k8s-github-robot pushed a commit that referenced this pull request Jul 25, 2017
…49328-upstream-release-1.7

Automatic merge from submit-queue

Automated cherry pick of #49498 #49328

Cherry pick of #49498 #49328 on release-1.7.

#49498: kubeadm: Make sure --config can be mixed with --skip-* flags
#49328: kubeadm: don't customize etcd selinux label
@k8s-cherrypick-bot
Copy link

Commit found in the "release-1.7" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. 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.

kubeadm init: can't skip preflight checks if config is provided
7 participants