-
Notifications
You must be signed in to change notification settings - Fork 922
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
WSL2 -very slow bash autocompletion since version 1.26.0 #1336
Comments
@returntrip: This issue is currently awaiting triage. SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues 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. |
Thanks @returntrip for the report. How do you setup shell completion? |
Ubuntu was 1.25.2 I just But I have also trying sourcing directly on the shell |
So now you are running kubectl 1.26. What version of kubectl were you running before? I'm asking because the only change I'm aware of between 1.25 and 1.26 is that we've enabled completion descriptions. However we've also tested for performance for this change. On the other hand, if you were previously running an even older kubectl, then the problem may be something else that changed before 1.26 |
Sorry maybe I was not clear when I provided the versions in the original message and also above: The kubectl versions were: For Ubuntu: 1.25.2 Or, are you looking for some other version numbers or the output of Please let me know! |
Sorry, my mistake. I saw "Ubuntu" and didn't even look at the version assuming it was your os version. |
There's a couple of things you could do to help us know what is the root cause: 1- turn off completion descriptions, which were added in 1.26.
2- Use the shell completion file of kubectl 1.25 with kubectl 1.26. This will show us if the slowdown is in the shell completion script or kubectl itself. Something like:
|
Thanks for providing troubleshooting steps. I have tried both ways and neither seem to speed up kubectl 1.26.0 completions. The interesting thing is that 1.25.5 works fine with the 1.26.0 completion descriptions. |
@returntrip Are you still having this problem?
That's interesting.
This will request completions from the kubectl binary just like the actual completion script does. |
I had the exact same problem, but as a newcomer to WSL (among Windows other blessings cough), I only experienced 1.26.0. Trying 1.25.5 fixed it, tested with bash and zsh.
The last commits seems to list stuff when completing plugin stuff, can't it be related to WSL slow IO ? Adding a single dummy plugin with 2 options doesn't change much, but hangs while completing mid second word too, while this seems to behave correctly with Happy to just downgrade to 1.25.5 for now anyway, and learned quite a lot about completion intricacies. |
Thanks for the info @Karocyt. This points to the fact that kubectl 1.26 now completes plugin names also, which goes through the entire list of paths present in To confirm you can check if listing plugins is slow by doing : |
EDIT: Removing all the Windows paths from Windows appends the content of the whole Windows So it is technically a WSL "bug", but this one was closed long ago (it seems that accessing Windows executables from WSL was one of their more appraised features, don't ask me why), so this will need a hack/fix on Kubernetes side... Maybe stripping if [[ $(grep -i Microsoft /proc/version) ]]; then
echo "Bash is running on WSL"
fi |
Ok so we know problem now. Thanks again @Karocyt ! Using the very long PATH should only affect completion for a limited set of scenarios:
Once kubectl detects it is doing completion for a plugin's arguments, it looks through the PATH variable looking for a script called BTW, this PATH problem will also make using any kubectl plugin very slow. This comment says you can actually configure WSL to not append the windows paths: microsoft/WSL#4234 (comment) But if you do need the windows paths to be included in PATH, there isn't much you can do... What I can think of is wrapping kubectl in a function that changes the PATH variable just for the kubectl invocation. |
The only Windows binary that I'm using (consciously) from within WSL is VSCode.exe aliased as A documentation page on usage with WSL should recommend to disable Windows Paths and set specific aliases for the binaries you need. |
Adding a section on kubectl + WSL to the docs sounds like a good idea. Please open that over at https://github.com/kubernetes/website. We can collect what should be in it there. /close |
@eddiezane: Closing this issue. In response to this:
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. |
The plugin I'm using -- https://github.com/rlipscombe/kubectl-ssh -- does provide a completion script, and it's in the first entry in PATH, so why is it still slow? |
Is it always slow? Or only for the first argument after Is it still slow when you do |
I looked at the code again. I see that when it’s doing completion for a specific plugin, the code still looks for all plugins. That would explain why things remain slow when the WSL path contains all the windows paths. I'm talking about this function:
this could be optimized. |
To be clear: it's still (tens of seconds) slow for |
Should this issue be reopened, or another one created? |
The only way to avoid the slow down in every scenario is to remove the Windows paths as described in comments further above. Optimizing the code as we've discussed would probably improve the situation for completing commands of a plugin but only if, as you have taken the time to insure, the completion script of the plugin is in the first path on the list. It would still not improve completion for the first argument, e.g., So I would suggest opening a different issue explaining things, if you feel it's worth it, and after that it will depend if anyone feels it's worth working on. |
I know this is old and I can open a new issue if needed. I experience this same slowness on MacOS (Venturs 13.5) as well. kubectl version --short kubectl plugin list Unable to read directory "/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin" from your PATH: open /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin: no such file or directory. Skipping... /Users/xxxx/bin/kubectl-convert |
What happened:
Since updating to kubectl
1.26.0
on both my WSL2 distros (Ubuntu and Fedora Remix). Bash automcompletion is super slow.Ubuntu was 1.25.2
Fedora was 1.25.4
What you expected to happen:
Autocompletion should be as fast as < 1.26.0
How to reproduce it (as minimally and precisely as possible):
Update to 1.26.0. Type
kubectl
followed by TABAnything else we need to know?:
This seems to be a known issue in WSL. But, I am not experiencing it with other tools like:
flux
ortanzu
(for which I installed completions manually). So it seems a combination of a new version of kubectl and the WSL Windows Path "issue".Environment:
kubectl version
):cat /etc/os-release
):The text was updated successfully, but these errors were encountered: