Bug 1257889 - Wrong promotion message for oc attach regardless of parameter values
Summary: Wrong promotion message for oc attach regardless of parameter values
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: oc
Version: 3.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Fabiano Franz
QA Contact: Yan Du
URL:
Whiteboard:
Depends On:
Blocks: 1287414
TreeView+ depends on / blocked
 
Reported: 2015-08-28 10:29 UTC by Yadan Pei
Modified: 2016-05-12 17:08 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1287414 (view as bug list)
Environment:
Last Closed: 2016-05-12 17:08:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Yadan Pei 2015-08-28 10:29:38 UTC
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:

Comment 1 Fabiano Franz 2015-11-13 20:33:37 UTC
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.

Comment 2 Yadan Pei 2015-11-16 05:25:42 UTC
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).

Comment 3 Yadan Pei 2015-11-16 05:28:30 UTC
(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?

Comment 4 Fabiano Franz 2015-11-19 17:52:28 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.