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

Introduce --kubeconfig instead of --config #18806

Closed
wants to merge 3 commits into from

Conversation

soltysh
Copy link
Contributor

@soltysh soltysh commented Mar 2, 2018

@openshift-ci-robot openshift-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 2, 2018
@@ -32,7 +32,7 @@ func (o DiagnosticsOptions) detectClientConfig() (expected bool, detected bool)
return false, false
}
o.Logger().Notice("CED2011", "Determining if client configuration exists for client/cluster diagnostics")
confFlagName := config.OpenShiftConfigFlagName
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks breaking. They're doing odd things and you have to tolerate both right? Add a test that would have caught 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.

@sosiouxme I'll defer to you. We're trying to switch from --config to --kubeconfig and deprecated the former, does this fix look right?

Copy link
Contributor

Choose a reason for hiding this comment

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

@sosiouxme I'll defer to you. We're trying to switch from --config to --kubeconfig and deprecated the former, does this fix look right?

Does --config still work?

Copy link
Member

Choose a reason for hiding this comment

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

--config is still accepted but is ignored, aside from deprecation notice. That's a little surprising as this is only looking at the value of the flag, which (since both new and old have the same target) I expected to be the same regardless of which flag was looked up. But apparently flags store the value separately from the target.

So the old flag remains, but has no effect. The code needs to be updated to either look at both flags or look at the shared target.

Copy link
Contributor

Choose a reason for hiding this comment

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

--config is still accepted but is ignored, aside from deprecation notice.

@soltysh that won't work. Deprecated doesn't mean broken. The code needs to accept both.

that means it is probably broken elsewhere too.

Copy link
Member

Choose a reason for hiding this comment

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

I would actually not be surprised if this is the only place that looks at the flag itself as opposed to the value it sets. And I'd be happy to have it look at the value instead if I could figure out how to retrieve it... digging.

@@ -245,7 +245,7 @@ func (o *DiagnosticsOptions) bindCommonFlags(flags *flag.FlagSet) {
func (o *DiagnosticsOptions) bindClientFlags(flags *flag.FlagSet) {
o.ClientFlags = flag.NewFlagSet("client", flag.ContinueOnError) // hide the extensive set of client flags
o.Factory = osclientcmd.New(o.ClientFlags) // that would otherwise be added to this command
flags.AddFlag(o.ClientFlags.Lookup(config.OpenShiftConfigFlagName))
flags.AddFlag(o.ClientFlags.Lookup(kclientcmd.RecommendedConfigPathFlag))
Copy link
Contributor

Choose a reason for hiding this comment

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

looks breaking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sosiouxme same question

@@ -279,7 +279,7 @@ func (d *NetworkDiagnostic) getKubeConfig() ([]byte, error) {
// 2. Default admin config paths
// 3. Default openshift client config search paths
paths := []string{}
paths = append(paths, d.ClientFlags.Lookup(config.OpenShiftConfigFlagName).Value.String())
paths = append(paths, d.ClientFlags.Lookup(kclientcmd.RecommendedConfigPathFlag).Value.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

looks breaking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sosiouxme same question


GlobalFile: cmdconfig.RecommendedHomeFile,
EnvVar: cmdconfig.OpenShiftConfigPathEnvVar,
ExplicitFileFlag: kclientcmd.RecommendedConfigPathFlag,
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks breaking. Patches required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Breaking as in, this will be the default flag asking for kubeconfig. Isn't that what we need to to if we want to deprecate --config in 3.10?

Copy link
Contributor

Choose a reason for hiding this comment

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

Breaking as in, this will be the default flag asking for kubeconfig. Isn't that what we need to to if we want to deprecate --config in 3.10?

Does it respect --config at all anymore?

@@ -149,7 +148,7 @@ func newLoginOptions(server string, username string, password string, insecure b
func defaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig {
loadingRules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: ""}

flags.StringVar(&loadingRules.ExplicitPath, config.OpenShiftConfigFlagName, "", "Path to the config file to use for CLI requests.")
flags.StringVar(&loadingRules.ExplicitPath, clientcmd.RecommendedConfigPathFlag, "", "Path to the kubeconfig file to use for CLI requests.")
Copy link
Contributor

Choose a reason for hiding this comment

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

This somehow isn't breaking?

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 9, 2018
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 8, 2018
@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 8, 2018
} else {
flags.StringVar(&loadingRules.ExplicitPath, "kubeconfig", "", "Path to the kubeconfig file to use for CLI requests.")
}
flags.StringVar(&loadingRules.ExplicitPath, clientcmd.OpenShiftKubeConfigFlagName, "", "Path to the kubeconfig file to use for CLI requests.")
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be conditional. When running as kubectl we don't want this flag available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

} else {
flags.StringVar(&loadingRules.ExplicitPath, "kubeconfig", "", "Path to the kubeconfig file to use for CLI requests.")
}
flags.StringVar(&loadingRules.ExplicitPath, clientcmd.OpenShiftKubeConfigFlagName, "", "Path to the kubeconfig file to use for CLI requests.")
Copy link
Contributor

Choose a reason for hiding this comment

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

does binding the same flag twice actually work? Which one wins?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, multiple flags can bind to the same underlying value. last one parsed wins, just like if you specify the same flag multiple times:

oc --config foo.kubeconfig --config bar.kubeconfig get pods
error: stat bar.kubeconfig: no such file or directory

}

func NewPathOptionsWithConfig(configPath string) *kclientcmd.PathOptions {
return &kclientcmd.PathOptions{
GlobalFile: kclientcmd.RecommendedHomeFile,

EnvVar: kclientcmd.RecommendedConfigPathEnvVar,
ExplicitFileFlag: kclientcmd.OpenShiftKubeConfigFlagName,
ExplicitFileFlag: kclientcmd.RecommendedConfigPathFlag,
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks broken. Please explicitly check both flags with oc login and oc project

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added test to login.sh checking both login and project.

@@ -8,15 +8,15 @@ import (
)

func NewPathOptions(cmd *cobra.Command) *kclientcmd.PathOptions {
return NewPathOptionsWithConfig(kcmdutil.GetFlagString(cmd, kclientcmd.OpenShiftKubeConfigFlagName))
return NewPathOptionsWithConfig(kcmdutil.GetFlagString(cmd, kclientcmd.RecommendedConfigPathFlag))
}

func NewPathOptionsWithConfig(configPath string) *kclientcmd.PathOptions {
return &kclientcmd.PathOptions{
Copy link
Contributor

Choose a reason for hiding this comment

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

I was expecting a patch in this type that allowed the specification of two explicit flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@soltysh
Copy link
Contributor Author

soltysh commented May 10, 2018

/refresh

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@soltysh
Copy link
Contributor Author

soltysh commented May 10, 2018

Ha, my problem was with wrong apostrophes in login.sh let's wait for the test results now.

@soltysh
Copy link
Contributor Author

soltysh commented May 22, 2018

/retest

@openshift-ci-robot
Copy link

@soltysh: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/extended_networking_minimal 7c6f2c2 link /test extended_networking_minimal
ci/openshift-jenkins/end_to_end 21b0277 link /test end_to_end
ci/openshift-jenkins/extended_conformance_install 21b0277 link /test extended_conformance_install
ci/openshift-jenkins/gcp 21b0277 link /test gcp
ci/openshift-jenkins/cmd 21b0277 link /test cmd

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 20, 2018
@openshift-bot
Copy link
Contributor

@soltysh: PR needs rebase.

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.

@soltysh
Copy link
Contributor Author

soltysh commented Aug 22, 2018

Closing in favor of #20721.

@soltysh soltysh closed this Aug 22, 2018
@soltysh soltysh deleted the kubeconfig branch August 22, 2018 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants