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

profile <name>: error acquiring lock for x: Name "-x" not valid #5436

Closed
galderz opened this issue Sep 23, 2019 · 4 comments · Fixed by #5439
Closed

profile <name>: error acquiring lock for x: Name "-x" not valid #5436

galderz opened this issue Sep 23, 2019 · 4 comments · Fixed by #5439
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Milestone

Comments

@galderz
Copy link

galderz commented Sep 23, 2019

Trying Minikube 1.4.0 and seeing this error when setting the profile name:

minikube profile operator-minikube
😿  Error while setting kubectl current context :  writing kubeconfig: Error writing file operator-minikube: error acquiring lock for operator-minikube: Name "-operator-minikube" not valid

Seems like a bug? I did prefix any - into the profile name.

@tstromberg tstromberg added the kind/bug Categorizes issue or PR as related to a bug. label Sep 23, 2019
@tstromberg tstromberg changed the title Name not valid error setting profile name in 1.4.0 profile <name>: error acquiring lock for x: Name "-x" not valid Sep 23, 2019
@tstromberg
Copy link
Contributor

Yup, this is definitely a bug.

 ~  minikube profile y
✅  Created a new profile : y
😿  Error while setting kubectl current context :  writing kubeconfig: Error writing file y: error acquiring lock for y: Name "-y" not valid
✅  minikube profile was successfully set to y

@tstromberg tstromberg added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Sep 23, 2019
@tstromberg tstromberg added this to the v1.5.0 milestone Sep 23, 2019
@afbjorklund
Copy link
Collaborator

afbjorklund commented Sep 23, 2019

Apparently mutex cannot use the name that itself constructs (by escaping stuff with dashes)

	validName = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9-]*$")

@afbjorklund
Copy link
Collaborator

Something is definitely weird with those CurrentContext functions, and the parameter order.

cmd/minikube/cmd/config/profile.go:                             err := kubeconfig.SetCurrentContext(constants.KubeconfigPath, profile)
pkg/minikube/kubeconfig/context.go:func SetCurrentContext(name string, configPath ...string) error {

cmd/minikube/cmd/stop.go:       err = kubeconfig.UnsetCurrentContext(constants.KubeconfigPath, machineName)
pkg/minikube/kubeconfig/context.go:func UnsetCurrentContext(machineName string, configPath ...string) error {

See how path and name is sent to name and path ? That sounds wrong...

@afbjorklund
Copy link
Collaborator

Bettter now, it actually locks ~/.kube/config instead of trying to lock ./foo (and failing miserably)

Also fixed the similar issue where minikube stop failed to match the current context name (with path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants