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
kubectl: error: open .lock: no such file or directory #118564
Comments
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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. |
Alright, turns out my CWD directory was a removed directory (I deleted it in another shell).
↑ this was the clue. Why does kubectl create .lock in CWD though? Does that mean it would fail if my CWD was a read-only filesystem? Is this intended? I don't think that's safe. Do you? |
/sig cli |
Lock is only used to modify kubeconfig to prevent multiple writes as you can see here kubernetes/staging/src/k8s.io/client-go/tools/clientcmd/config.go Lines 173 to 176 in 9173414
unlock function).
But your kubectl version seems to be old. Could you please try with the new one?. Thanks. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
@ardaguclu thank you for the explanation. Regardless, I still think it it a rather bad idea to try and create any files in cwd, whether it's a lock file that's removed immediately after or not. IMO the right way is to create such files in a predefined full-path (e.g. ~/.kube/.lock) rather than whereever the user is in (e.g. a network filesystem, an application's directory that's monitoring said directory for any changes and can crash if an unrecognized file is created there, etc.) |
I tried to reproduce this, deleted my cwd, and the command still succeeded (I'm using kubectl 1.28, but also tried 1.22 and it worked for both versions):
It looks like the code attempts to create a lock file relative to the config file, not the cwd: kubernetes/staging/src/k8s.io/client-go/tools/clientcmd/config.go Lines 167 to 176 in 856bb5c
kubernetes/staging/src/k8s.io/client-go/tools/clientcmd/loader.go Lines 464 to 470 in 2ea6896
@netikras Am I misunderstanding the problem? Do you have a different way to reproduce it than what I attempted above? |
What happened?
Yesterday this command was working perfectly. Today it's not
Excerpt from strace:
What did you expect to happen?
I was hoping kubectl would switch contexts
How can we reproduce it (as minimally and precisely as possible)?
No clue
Anything else we need to know?
No response
Kubernetes version
Cloud provider
OS version
The text was updated successfully, but these errors were encountered: