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 exec documentation needs to make it clear that the command shouldn't be quoted #7688

Closed
aronchick opened this Issue May 4, 2015 · 6 comments

Comments

Projects
None yet
6 participants
@aronchick
Contributor

aronchick commented May 4, 2015

Repro:

  • Use gcloud alpha container kubectl exec -p <pod> -c <container> -i -t -- '<command>'
  • Observe that when = one very small command ls or date it works properly
  • Observe that when is even slightly more complex = ls /usr it fails with "env: ls /usr: No such file or directory"
# [18:04:44]
$ gcloud alpha container kubectl exec -p rails-mmlpb -c rails -i -t 'ls'
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr

# [18:04:56]
$ gcloud alpha container kubectl exec -p rails-mmlpb -c rails -i -t 'ls /usr'
env: ls /usr: No such file or directory

Expected: Command should execute as though exactly the same way docker exec works.

@roberthbailey

This comment has been minimized.

Member

roberthbailey commented May 4, 2015

David, thanks for the bug report. Can you try doing this with kubectl directly (rather than the wrapped version) and see if you see the same error? I'm trying to figure out if this is a problem with our wrapping in GKE or with kubectl itself.

Also, can you run gcloud alpha container kubectl version -c and gcloud version for me as well?

@aronchick

This comment has been minimized.

Contributor

aronchick commented May 4, 2015

Sure thing:

$ gcloud alpha container kubectl version -c
Client Version: version.Info{Major:"0", Minor:"15", GitVersion:"v0.15.0",
GitCommit:"831f3e60d7cd64c61a775d6c78acce1673dd8aa9", GitTreeState:"clean"}

$ gcloud version
Google Cloud SDK 0.9.58

alpha 2015.04.09
bq 2.0.18
bq-nix 2.0.18
compute 2015.04.29
core 2015.04.29
core-nix 2014.10.20
dns 2015.04.29
gcloud 2015.04.29
gcloud-extensions-darwin-x86_64 0.15.0
gcutil 1.16.5
gcutil-nix 1.16.5
gsutil 4.12
gsutil-nix 4.6
preview 2015.04.29
sql 2015.04.09

I'll run kubectl on it in the morning.

On Sun, May 3, 2015 at 9:56 PM, Robert Bailey notifications@github.com
wrote:

David, thanks for the bug report. Can you try doing this with kubectl
directly (rather than the wrapped version) and see if you see the same
error? I'm trying to figure out if this is a problem with our wrapping in
GKE or with kubectl itself.

Also, can you run gcloud alpha container kubectl version -c and gcloud
version for me as well?


Reply to this email directly or view it on GitHub
#7688 (comment)
.

@ncdc

This comment has been minimized.

Member

ncdc commented Sep 30, 2015

@aronchick try it without putting the command in quotes. In other words, ... rails -i -t ls /usr. If you need to pass flags to the command, you can separate the kubectl flags from the command's flags with --; i.e., ... rails -i -t -- ls -t /usr

@bgrant0607 bgrant0607 changed the title from Unable to execute (almost) anything via "kubectl exec" to kubectl exec documentation needs to make it clear that the command shouldn't be quoted Oct 8, 2015

@aronchick

This comment has been minimized.

Contributor

aronchick commented Oct 16, 2015

Correct, the failure here is the two errors side by side:

$ cluster/kubectl.sh exec -p client-blue-8yw37 -c client -i -t -- ls -t /usr
W1016 13:45:56.951392    4341 cmd.go:161] -p POD is DEPRECATED and will be removed in a future version. Use exec POD instead.
local  bin  share  lib  include  sbin  games  src

$ cluster/kubectl.sh exec -p client-blue-8yw37 -c client -i -t -- 'ls -t /usr'
W1016 13:46:15.354560    4370 cmd.go:161] -p POD is DEPRECATED and will be removed in a future version. Use exec POD instead.
Cannot run exec command bbc103a296ee2a28e1b55d2315ed111efbe4ac2a6a44bb236919bd53bf0816f1 in container 1df024a230afc5a752fa1b358885febbc8b8d0bdc29c1d54f29bf3b0a3358fcf: [8] System error: exec: "ls -t /usr": stat ls -t /usr: no such file or directory
                                                                                 Error starting exec command in container bbc103a296ee2a28e1b55d2315ed111efbe4ac2a6a44bb236919bd53bf0816f1: Cannot run exec command bbc103a296ee2a28e1b55d2315ed111efbe4ac2a6a44bb236919bd53bf0816f1 in container 1df024a230afc5a752fa1b358885febbc8b8d0bdc29c1d54f29bf3b0a3358fcf: [8] System error: exec: "ls -t /usr": stat ls -t /usr: no such file or directory

It'd be really great to (somehow) detect the quoting and warn them.

@kargakis

This comment has been minimized.

Member

kargakis commented Mar 20, 2017

@shiywang

This comment has been minimized.

Member

shiywang commented Mar 22, 2017

I will take a look

k8s-merge-robot added a commit that referenced this issue May 23, 2017

Merge pull request #43663 from shiywang/quato
Automatic merge from submit-queue (batch tested with PRs 38990, 45781, 46225, 44899, 43663)

Fix command exec -- COMMAND can not contain spaces

Fixes #7688
the problem is when you execute command:
 `cluster/kubectl.sh exec -p client-blue-8yw37 -c client -i -t -- 'ls -t /usr'`
the args is 
[`client-blue-8yw37` , `ls -t /usr`] 
**instead of** 
[`client-blue-8yw37`, `ls`, `-t`, `/usr`]
@kubernetes/sig-cli-pr-reviews, so I add a warning, wdyt ?
cc @ymqytw @adohe @fabianofranz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment