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

Fix order of parameters to CurrentContext funcs #5439

Merged
merged 1 commit into from
Sep 27, 2019

Conversation

afbjorklund
Copy link
Collaborator

Apparently it is easy to get name and path swapped around.

Fixes #5436

Also fixes the issue where "stop" didn't unset the current-context (due to profile name not matching).

Apparently it is easy to get name and path swapped around.
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 23, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afbjorklund

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 23, 2019
@@ -77,7 +77,7 @@ func runStop(cmd *cobra.Command, args []string) {
}

machineName := pkg_config.GetMachineName()
err = kubeconfig.UnsetCurrentContext(constants.KubeconfigPath, machineName)
err = kubeconfig.UnsetCurrentContext(machineName, constants.KubeconfigPath)
Copy link
Contributor

@tstromberg tstromberg Sep 23, 2019

Choose a reason for hiding this comment

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

This PR caused me to LOL because of how easy it was, but sad because of how difficult to detect it was.

There is a second hidden bug here: constants.KubeconfigPath does not respect the KUBECONFIG environment variable. If the filename isn't provided, we do the right thing. Here is my suggested change to reduce the number of paths to sadness in our code base:

  • Change *SetCurrentContext to either take a second argument, or not take a second argument. Having to support two behaviors in one function is a recipe for future mistakes.
  • If you prefer the 1-argument version, update context_test.go to set the temp path via an alternative mechanism, such as KUBECONFIG
  • If you prefer the 2-argument version, update these the kubeconfig.*Context() calls to pass kubeconfig.PathFromEnv().

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

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

Ah ! Great catch

@tstromberg tstromberg merged commit 90bf0f8 into kubernetes:master Sep 27, 2019
@afbjorklund
Copy link
Collaborator Author

Never got around to updating this PR, but you can of course still improve SetCurrentContext more

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

profile <name>: error acquiring lock for x: Name "-x" not valid
4 participants