Bug 1469411

Summary: Can`t copy local directory & files to correct directory & files in a remote pod through "oc cp".
Product: OpenShift Container Platform Reporter: xipang
Component: ocAssignee: Juan Vallejo <jvallejo>
Status: CLOSED ERRATA QA Contact: Xingxing Xia <xxia>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.6.0CC: aos-bugs, bmcelvee, ffranz, jokerman, jvallejo, mmccomas
Target Milestone: ---Keywords: Rebase
Target Release: 3.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-03-28 14:06:20 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 xipang 2017-07-11 08:47:06 UTC
Description of problem:
Can`t copy local directory & files to correct directory & files in a remote pod through "oc cp".

Version-Release number of selected component (if applicable):
oc v3.6.140
kubernetes v1.6.1+5115d708d7
features: Basic-Auth GSSAPI Kerberos SPNEGO

How reproducible:
Always

Steps to Reproduce:
1.oc login and create two projects 
$oc new-project newproj02
$oc new-project newproj01

2.create application(e.g.ruby) in newproj01 and prepare files & dirs
2.1 Prepare local dirs /tmp/foo_dir 
2.2 Prepare local files /tmp/foo /tmp/bar /tmp/foo_2 /tmp/foo_dir/foo.local
$cat >>/tmp/foo<<-EOF
> Copy from local.
> EOF
$cat >>/tmp/foo_2<<-EOF
> Copy from local.
> EOF
2.3 Prepare pod files /tmp/foo_pod /tmp/bar /tmp/bar_2 and dirs /tmp/bar_dir in a remote pod

3.Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the current namespace
$oc cp /tmp/foo_dir ruby-1-4fcv8:/tmp/bar_dir

4.Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container
$oc cp /tmp/foo ruby-1-4fcv8:/tmp/bar -c ruby

5.Copy /tmp/foo_2 local file to /tmp/bar_2 in a remote pod in namespace <some-namespace>
$oc project newproj02
$oc cp /tmp/foo_2 newproj01/ruby-1-4fcv8:/tmp/bar_2

6.Copy /tmp/foo_pod from a remote pod to /tmp/bar locally
$oc cp newproj01/ruby-1-4fcv8:/tmp/foo_pod /tmp/bar

Actual results:
3.foo.local file not in /tmp/bar_dir directory in pod,but foo_dir directory was copied to /tmp directory 
$oc rsh ruby-1-4fcv8
$cat /tmp/bar_dir/foo.local
cat: /tmp/bar_dir/foo.local: No such file or directory
$ls /tmp
... foo_dir ...

4. foo local file content wasn't copied to bar file in pod,but foo local file was copied to /tmp directory
$oc rsh ruby-1-4fcv8
$ls /tmp
... foo ...

5.Same as step 4

6. Can copy successfully, but it shows msg " tar: Removing leading `/' from member names"

Expected results:
3.$oc rsh ruby-1-4fcv8
$ls /tmp/bar_dir
foo.local

4.$cat /tmp/bar
Copy from local.

5. Same as step 4

6. The msg is better to be removed


Additional info:

Comment 1 Juan Vallejo 2017-08-23 15:13:39 UTC
Origin PR: https://github.com/openshift/origin/pull/15929

Comment 2 Juan Vallejo 2017-08-23 15:48:00 UTC
> 6. The msg is better to be removed

"Removing leading `/' from member names" is output as part of the `tar` pkg. I think it makes sense to leave this warning

Comment 3 Juan Vallejo 2017-08-23 19:06:33 UTC
Upstream PR: https://github.com/kubernetes/kubernetes/pull/51215

Comment 4 Juan Vallejo 2017-08-25 20:04:25 UTC
Marking as "UpcomingRelease" this is entirely an upstream patch [1]; changes will be brought in with the next rebase. Closing downstream pull [2].

1. https://github.com/kubernetes/kubernetes/pull/51215
2. https://github.com/openshift/origin/pull/15929

Comment 5 Juan Vallejo 2017-10-12 19:39:08 UTC
Upstream PR [1] has merged. Bug will be fixed next rebase. Marking as UpcomingRelease

Comment 6 Fabiano Franz 2017-12-07 18:21:49 UTC
Fixed in 3.8.

Comment 8 Xingxing Xia 2018-01-05 03:22:38 UTC
Testing with latest v3.8 oc v3.8.26, the bug still exists. Testing with latest v3.9 oc v3.9.0-0.16.0, the bug is fixed. Results are followed
Saw "Flags: aos-3.9.0+" was added and the errata advisory is for 3.9, thus it is inferred "Target Release" 3.8.0 is outdated and will being updated

$ oc version
oc v3.9.0-0.16.0
kubernetes v1.9.0-beta1
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https://api.free-int.openshift.com:443
openshift v3.8.18
kubernetes v1.8.1+0d5291c

$ oc cp /tmp/foo_dir $POD:/tmp/bar_dir # Will get same result when with or without '/' is given after '/tmp/bar_dir'
$ oc rsh $POD
sh-4.2$ ls /tmp/bar_dir
foo.local

$ oc cp /tmp/foo $POD:/tmp/bar -c ruby
$ oc rsh $POD
sh-4.2$ ls /tmp/bar
bar

> The msg is better to be removed
As to this, the msg still exists. IMO it is acceptable

Comment 12 errata-xmlrpc 2018-03-28 14:06:20 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-2018:0489