Bug 1287414 - Wrong prompt message for oc attach regardless of parameter values
Wrong prompt message for oc attach regardless of parameter values
Status: CLOSED ERRATA
Product: OpenShift Container Platform
Classification: Red Hat
Component: Command Line Interface (Show other bugs)
3.1.0
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Fabiano Franz
Wei Sun
:
Depends On: 1257889
Blocks:
  Show dependency treegraph
 
Reported: 2015-12-01 22:04 EST by yapei
Modified: 2016-01-26 14:19 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1257889
Environment:
Last Closed: 2016-01-26 14:19:21 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description yapei 2015-12-01 22:04:03 EST
+++ This bug was initially created as a clone of Bug #1257889 +++

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:

--- Additional comment from Fabiano Franz on 2015-11-13 15:33:37 EST ---

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.

--- Additional comment from  on 2015-11-16 00:25:42 EST ---

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).

--- Additional comment from  on 2015-11-16 00:28:30 EST ---

(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?

--- Additional comment from Fabiano Franz on 2015-11-19 12:52:28 EST ---

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.
Comment 1 yapei 2015-12-03 02:14:33 EST
Will verify once new puddle is available
Comment 2 yapei 2015-12-03 02:16:17 EST
On this version of Atomic Enterprise and Openshift Enterprise,
oc v3.1.0.4-16-g112fcc4
kubernetes v1.1.0-origin-1107-g4c8e6f4

it is still not fixed
Comment 3 yapei 2015-12-08 03:18:28 EST
bug fixed still not merged to latest puddle in 2015-12-07
Comment 4 Fabiano Franz 2015-12-08 09:32:36 EST
That's expected, we are not yet doing daily OSE builds since the 3.1 release. We'll get back to doing it most likely later this week.
Comment 5 yapei 2015-12-08 22:17:56 EST
Checked on 12-08 puddle,

oc v3.1.0.3-16-gcf75fd9
kubernetes v1.1.0-origin-1107-g4c8e6f4

fixed is merged and works well
Comment 7 errata-xmlrpc 2016-01-26 14:19:21 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2016:0070

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