-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 kubectl tab-completion and improve error messages #14868
Fix kubectl tab-completion and improve error messages #14868
Conversation
|
Welcome @oldium! |
Hi @oldium. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
Can one of the admins verify this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oldium thank you for this PR, have you checked if this PR will break other use cases?
we do not have enough unit-test or integration test arround this
I am not sure, really. I figured out now that the error could be as well fixed when the |
The actual fix could be: if len(args) > 1 && args[0] != "--help" {
cluster := []string{"--cluster=" + cname}
args = append(cluster, args...)
} or if len(args) > 0 {
cluster := []string{"--cluster=" + cname}
args = append(cluster, args...)
} or even cluster := []string{"--cluster=" + cname}
args = append(cluster, args...) Tested all versions ( For the code completion the |
Please advise which version should I put into the patch 😊 |
ca2f7c3
to
017996b
Compare
Updated patch to be the simplest version (no minikube.exe kubectl
minikube.exe kubectl --help
minikube.exe kubectl -- --help
minikube.exe kubectl __complete app
minikube.exe kubectl __complete logs `"`"
minikube.exe kubectl get pods And the output looks good, plain |
/ok-to-test |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
017996b
to
8b23826
Compare
Updated patch to insert the cluster argument before other flags, but after commands to improve error message from kubectl. In case of code completion (__complete arg), insert cluster argument at the beginning. |
8b23826
to
49ba81c
Compare
affff4f
to
c662261
Compare
Updated description and commit-message to contain the full reasoning behind the solution. Rebased to latest master. If there is anything more to be solved in |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Try to fix the following issues when `kubectl` is an alias for `minikube kubectl --` and tab-completion for `kubectl` is enabled: 1. When `--cluster name` form of command-line option is used, it conflicts with argument parsing, `name` is interpreted as plugin name. Call to `kubectl --cluster test help` leads to error `Error: flags cannot be placed before plugin name: --cluster`. Fix this by using `--cluster=name` form, which is correctly handled also in call `kubectl --cluster=test help`. 2. When `--cluster=name` is added as first argument (as seen in original code), it still leads to error mentioned above when the command is unknown like in the call `kubectl --cluster=test unknown`. Fix this by inserting `--cluster=name` after all (sub-)commands and before any flags/options. 3. The original code passed `--cluster=name` to normal `kubectl` calls, but omitted it for tab-completion calls. This might lead to wrong tab suggestions about pods, deployments and the like. Fix this by always adding `--cluster=name` option to the command line. 4. In case of tab-completion, put the `--cluster=name` immediately after `__complete` command to prevent any interference with incomplete commands (just in case). This works fine and does not generate any errors like mentioned in point 2.
c662261
to
6d28d2a
Compare
@oldium Sorry for the delay, I just rebased the PR, is this good to go now? |
kvm2 driver with docker runtime
Times for minikube start: 52.0s 52.7s 52.0s 53.0s 52.2s Times for minikube ingress: 27.8s 27.4s 28.9s 29.3s 30.2s docker driver with docker runtime
Times for minikube start: 25.6s 25.8s 25.2s 25.1s 22.5s Times for minikube (PR 14868) ingress: 20.9s 20.9s 21.9s 19.9s 21.4s docker driver with containerd runtime
Times for minikube start: 23.5s 23.7s 21.5s 23.7s 23.5s Times for minikube ingress: 31.4s 31.4s 31.4s 31.4s 31.4s |
@spowelljr No problem with the delay, that is normal 😊 Looks good, ready to go 👍 |
These are the flake rates of all failed tests.
To see the flake rates of all tests by environment, click here. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: oldium, spowelljr 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 |
Try to fix the following issues when
kubectl
is an alias forminikube kubectl --
and tab-completion forkubectl
is enabled:--cluster name
form of command-line option is used, it conflicts with argument parsing,name
is interpreted as plugin name. Call tokubectl --cluster test help
leads to errorError: flags cannot be placed before plugin name: --cluster
. Fix this by using--cluster=name
form, which is correctly handled also in callkubectl --cluster=test help
.--cluster=name
is added as first argument (as seen in original code), it still leads to error mentioned above when the command is unknown like in the callkubectl --cluster=test unknown
. Fix this by inserting--cluster=name
after all (sub-)commands and before any flags/options.--cluster=name
to normalkubectl
calls, but omitted it for tab-completion calls. This might lead to wrong tab suggestions about pods, deployments and the like. Fix this by always adding--cluster=name
option to the command line.--cluster=name
immediately after__complete
command to prevent any interference with incomplete commands (just in case). This works fine and does not generate any errors like mentioned in point 2.Fixes #12938