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:
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
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
Fix in https://github.com/openshift/origin/pull/22653
This was merged long time ago but never got properly moved, moving to qa to verify.
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
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