Description of problem: 'oc rsh -h' gives the help information about command, when follow the instruction to execute some commands in format 'oc rsh POD [command] -t/-T/-c',-t/-T/-c is regarded as argument of [command] passed in oc rsh Version-Release number of selected component (if applicable): oc v1.0.6-37-gaece681 kubernetes v1.1.0-alpha.0-1605-g44c91b1 devenv-fedora_2348 How reproducible: Always Steps to Reproduce: 1. Create a pod with two containers, wait the pod to be Running $ oc create -f https://raw.githubusercontent.com/openshift-qe/v3-testfiles/master/pods/pod_with_two_containers.json 2. Check 'oc rsh' help info $ oc rsh -h Usage: oc rsh POD [command] [options] Examples: // Open a shell session on the first container in pod 'foo' $ oc rsh foo // Run the command 'cat /etc/resolv.conf' inside pod 'foo' $ oc rsh foo cat /etc/resolv.conf Options: -c, --container='': Container name; defaults to first container -T, --no-tty=false: Disable pseudo-terminal allocation --shell='/bin/bash': Path to shell command -t, --tty=false: Force a pseudo-terminal to be allocated 3. Use 'oc rsh' behaviour to execute command in container (a)$ oc rsh doublecontainers ls -T (b)$ oc rsh -T doublecontainers ls bin dev etc hello-openshift ...... (c)$ oc rsh doublecontainers date -c hello-openshift-fedora 4. Check -t and -T options for ssh commmand $ man ssh ssh [-1246AaCfGgKkMNnqsTtVvXxYy]...... [user@]hostname [command] [-t] and [-T] options are before the [command] option Actual results: step2: $ oc rsh -h Usage: oc rsh POD [command] [options] Examples: // Open a shell session on the first container in pod 'foo' $ oc rsh foo // Run the command 'cat /etc/resolv.conf' inside pod 'foo' $ oc rsh foo cat /etc/resolv.conf Options: -c, --container='': Container name; defaults to first container -T, --no-tty=false: Disable pseudo-terminal allocation --shell='/bin/bash': Path to shell command -t, --tty=false: Force a pseudo-terminal to be allocated step3: (a)$ oc rsh doublecontainers ls -T ls: option requires an argument -- 'T' Try 'ls --help' for more information. error: error executing remote command: Error executing command in container: Error executing in Docker Container: 2 (c)$ oc rsh doublecontainers date -c hello-openshift-fedora date: invalid option -- 'c' Try 'date --help' for more information. error: error executing remote command: Error executing command in container: Error executing in Docker Container: 1 Expected results: In the help info, [command] should behind the [option], like oc rsh POD [options] [command] only in this way, -t and -T option will not be treated as a argument of command. otherwise, it will give wrong direction for users to use 'oc rsh'command step3(a) 'ls' command is executed and result is returned step3(c) `date` command should be executed in container 'hello-openshift-fedora' Additional info: If we specify -T option for interactive command, it will hang $ oc rsh -c hello-openshift-fedora -T doublecontainers bash $ oc rsh -c hello-openshift-fedora -T doublecontainers /usr/bin/python
Fixed in https://github.com/openshift/origin/pull/6619. Note that we still have [options] in the end for the command options, but added [options] for the rsh command.
Commit pushed to master at https://github.com/openshift/origin https://github.com/openshift/origin/commit/0741048c36a2fdc7fbd70dba72ccb960ca5bab78 Bug 1263609 - fix oc rsh usage
checked on devenv-rhel7_3145, when -c option is carried, 'oc rsh doublecontainers --container=hello-openshift-fedora‘ There is still error info printed, exec: "--container=hello-openshift-fedora": executable file not found in $PATH error: error executing remote command: Error executing command in container: Error executing in Docker Container: -1 when other option (-T/-t) is carried, same problem happens
Fixed the usage in https://github.com/openshift/origin/pull/7895.
checked against devenv-rhel7_3688, 1. Check 'oc rsh' usage Usage: oc rsh POD [options] [COMMAND] 2. [options] are placed behind POD # oc rsh doublecontainers -c hello-openshift-fedora cat /etc/system-release exec: "-c": executable file not found in $PATH 3. [options] are placed before POD # oc rsh -c hello-openshift-fedora doublecontainers cat /etc/system-release Fedora release 21 (Twenty One) 4. Compared with 'oc exec' # oc exec doublecontainers -c hello-openshift-fedora cat /etc/system-release Fedora release 21 (Twenty One) From step2, when [options] comes after POD, it gives error info. I think this is wrong behaviour because help info says [options] comes after POD, current solution didn't match help info. Another issue, In the help info, it says "will attempt to use '/bin/bash' as the default shell", please see this command # oc rsh doublecontainers sh-4.2$ echo $BASH /bin/sh sh-4.2$ ps PID TTY TIME CMD 55 ? 00:00:00 sh 59 ? 00:00:00 ps it seems that /bin/sh is used instead of /bin/bash. Please check these problems
Good catch, rsh usage is fixed in https://github.com/openshift/origin/pull/7946.
checked against devenv-rhel7_3705 Now the command works well # oc rsh -c hello-openshift-fedora doublecontainers sh-4.3$ cat /etc/system-release Fedora release 21 (Twenty One) sh-4.3$ exit exit # oc rsh --container=hello-openshift-fedora doublecontainers sh-4.3$ cat /etc/system-release Fedora release 21 (Twenty One) sh-4.3$ exit exit # oc rsh --container=hello-openshift-fedora doublecontainers cat /etc/system-release Fedora release 21 (Twenty One) # oc rsh --container=hello-openshift-fedora --shell=/bin/bash doublecontainers bash-4.3$ exit Move to VERIFIED