Description of problem: Always show wrong message for oc attach regardless of parameter values Version-Release number of selected component (if applicable): oc v1.0.5-71-gb6650dd kubernetes v1.1.0-alpha.0-1605-g44c91b1 How reproducible: Always Steps to Reproduce: 1.Create a project 2.When there is no pod named "123456-7890",check 'oc attach' functionality with only POD parameter carried $ oc attach 123456-7890 Error from server: pods "123456-7890" not found 3.Check 'oc attach' with more parameter $ oc attach 123456-7890 date $ oc attach 123456-7890 -c ruby-container date 4. Create a pod with two containers $ oc create -f https://raw.githubusercontent.com/openshift-qe/v3-testfiles/master/pods/pod_with_two_containers.json 5. Check pods if it is in running status $ oc get pods NAME READY STATUS RESTARTS AGE doublecontainers 2/2 Running 0 8m 6. Check oc attach functionality $ oc attach doublecontainers date $ oc attach doublecontainers -c hello-openshift date Actual results: actual result for step3: error: expected a single argument: POD, saw 2: [123456-7890 date] see 'oc attach -h' for help. actual result for step6: error: expected a single argument: POD, saw 2: [doublecontainers date] see 'oc attach -h' for help. Expected results: Expected result for step3: Should promote message indicating "pods "123456-7890" not found" Expected result for step6: Should get date information from first container of pod 'doublecontainers' Additional info:
The example in 'oc attach' was wrong. This command is not supposed to receive more than one argument (the pod name), since it's not supposed to run commands specified by the user like 'oc exec', but attach to the current process instead. The example was fixed in: https://github.com/openshift/origin/pull/5898 In case the user provides more than one argument, we must throw the error stating that it only takes one arg, and this validation happens before checking if the pod name is valid or not.
Verified on devenv-rhel7_2712 oc v1.1-25-g0c0e452 kubernetes v1.1.0-origin-1107-g4c8e6f4 When there are more than one arguments carried, it gave error info. # oc attach doublecontainers date whoami error: expected a single argument: POD, saw 3: [doublecontainers date whoami] See 'oc attach -h' for help and examples. # oc attach doublecontainers -c hello-openshift date whoami error: expected a single argument: POD, saw 3: [doublecontainers date whoami] # oc attach -h Attach to a running container Attach the current shell to a remote container, returning output or setting up a full terminal session. Can be used to debug containers and invoke interactive commands. Usage: oc attach POD -c CONTAINER [options] Examples: # Get output from running pod 123456-7890, using the first container by default $ oc attach 123456-7890 # Get output from ruby-container from pod 123456-7890 $ oc attach 123456-7890 -c ruby-container # Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod 123456-780 # and sends stdout/stderr from 'bash' back to the client $ oc attach 123456-7890 -c ruby-container -i -t Options: -c, --container='': Container name. If omitted, the first container in the pod will be chosen -i, --stdin=false: Pass stdin to the container -t, --tty=false: Stdin is a TTY Use "oc options" for a list of global command-line options (applies to all commands).
(In reply to Fabiano Franz from comment #1) > The example in 'oc attach' was wrong. This command is not supposed to > receive more than one argument (the pod name), since it's not supposed to > run commands specified by the user like 'oc exec', but attach to the current > process instead. The example was fixed in: > > https://github.com/openshift/origin/pull/5898 > > In case the user provides more than one argument, we must throw the error > stating that it only takes one arg, and this validation happens before > checking if the pod name is valid or not. Just one thing to confirm, since 'oc attach' only attaches to process rather than running commands in container, how -i and-t will be used?
When used with -i -t, the command will also attach stdin to the running process of the remote container. If the remote process is interactive, this will allow you to send keystrokes from stdin and interact with it.