evanlucas / fish-kubectl-completions

kubectl completions for fish shell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Completion requests don't time out

charleskorn opened this issue · comments

Thanks for the great tool.

I have one minor issue: if I try to complete a command and the completion requires communicating with the cluster (eg. to get a list of pods), the completion never times out and so I'm stuck waiting for the completion to return before I can keep typing.

Steps to reproduce

  1. Get into a situation where communication with your Kubernetes cluster is impossible (eg. if you're running Minikube, run minikube stop, or if Kubernetes is on another machine, disconnect from the network)
  2. Open a shell and type kubectl get pods (with a trailing space), then press Tab
  3. The prompt freezes, waiting for the completion that will never come. The only way to cancel is to press Ctrl+C.

I'd expect it to time out after a few seconds - at the very least I should be able to continue typing but even better would be some kind of error message.

I'm very new to Fish so I'm not particularly confident sending a PR but I can give it a go if you're short on time. (Looks like kubectl's --request-timeout option is what would be required.)

Thanks for the great tool.

Thanks! Glad it is useful.

Do you have a preference on the timeout duration? Maybe we should make it configurable via an environment variable?

My initial thought is that it should be in the order of seconds (1-2sec?) - given you can't do anything until the completion function returns, I feel it should err on the side of failing fast rather than waiting longer in the hope of getting a response.

But it should definitely be configurable, I can see the need to make the timeout shorter or longer depending on different people's situations.

This has been completed. It is currently set to 5s, but can be changed if that is too long for your liking (https://github.com/evanlucas/fish-kubectl-completions#fish_kubectl_completion_timeout). Thanks!