Bug 1572149

Summary: `oc cp` with non-existent container or pod should prompt container or pod not found when copying from pod
Product: OpenShift Container Platform Reporter: Xingxing Xia <xxia>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: Xingxing Xia <xxia>
Severity: low Docs Contact:
Priority: medium    
Version: 3.10.0CC: aos-bugs, eparis, hasha, jokerman, mmccomas
Target Milestone: ---   
Target Release: 4.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-10-16 06:27:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Xingxing Xia 2018-04-26 09:38:05 UTC
Description of problem:
`oc cp -c` with wrong container should return container not valid when copying from pod.

Version-Release number of selected component (if applicable):
v3.10.0-0.29.0

How reproducible:
Always

Steps to Reproduce:
1. Given wrong container, copy things from pod to local:
oc cp -c euby-ex ruby-ex-1-8559q:/etc/hosts ./

2. Given wrong container, copy from local to pod:
oc cp -c euby-ex pod.yaml ruby-ex-1-8559q:/tmp


Actual results:
1. It shows:
error: etc/hosts no such file or directory

Given right container, it can succeed.

2. It shows:
Error from server (BadRequest): container euby-ex is not valid for pod ruby-ex-1-8559q

Expected results:
1. Should return container not valid like step 2

Additional info:

Comment 1 Xingxing Xia 2018-06-07 09:27:14 UTC
Similar when pod is not existent:
$ oc cp pod.yaml ruby-ex-1-bdc9m-typo:/tmp
Error from server (NotFound): pods "ruby-ex-1-bdc9m-typo" not found

$ oc cp ruby-ex-1-bdc9m-typo:/etc/hosts ./local/
error: etc/hosts no such file or directory

Comment 2 shahan 2018-06-11 07:51:34 UTC
Similiar when operate clusteradmin's pod with normal user:
[hasha@mypc cucushift]$ oc cp default/docker-registry-phf5b:/etc/hosts .
error: etc/hosts no such file or directory

Comment 4 Maciej Szulik 2019-04-24 13:35:02 UTC
Fix in https://github.com/openshift/origin/pull/22653

Comment 6 Maciej Szulik 2019-08-23 10:21:45 UTC
This was merged long time ago but never got properly moved, moving to qa to verify.

Comment 9 Xingxing Xia 2019-08-28 04:58:36 UTC
Verified in oc version: GitVersion:"v4.2.0", GitCommit:"1904cc55f", GitTreeState:"clean", BuildDate:"2019-08-28T02:28:30Z"
[xxia@fedora29 my]$ oc cp -c abc mysql-1-78msw:/etc/hosts ./
Error from server (BadRequest): container abc is not valid for pod mysql-1-78msw
[xxia@fedora29 my]$ oc cp -c abc pod.yaml mysql-1-78msw:/tmp
Error from server (BadRequest): container abc is not valid for pod mysql-1-78msw
[xxia@fedora29 my]$ oc cp ruby-ex-1-bdc9m-typo:/etc/hosts ./local/
Error from server (NotFound): pods "ruby-ex-1-bdc9m-typo" not found

Comment 11 errata-xmlrpc 2019-10-16 06:27:40 UTC
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/RHBA-2019:2922