Bug 1470962
Summary: | oc cp a file to container's folder will fail when the path doesn't ended up with slash | ||
---|---|---|---|
Product: | OpenShift Container Platform | Reporter: | XiaochuanWang <xiaocwan> |
Component: | oc | Assignee: | Juan Vallejo <jvallejo> |
Status: | CLOSED CURRENTRELEASE | QA Contact: | Xingxing Xia <xxia> |
Severity: | low | Docs Contact: | |
Priority: | medium | ||
Version: | 3.6.0 | CC: | aos-bugs, ffranz, jokerman, jvallejo, mmccomas, smunilla |
Target Milestone: | --- | Keywords: | Rebase |
Target Release: | 3.9.0 | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | v3.9.0-0.16.0 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2018-06-13 14:25:51 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
XiaochuanWang
2017-07-14 07:09:46 UTC
Right now, `oc cp` does not actually check to see if the destination path you provided exists, is a directory, etc. We simply take the "directory" portion of your destination argument as described in https://golang.org/pkg/path/#Dir: [Example 1] Local Source File: "test" Destination: "mypod:/tmp/" Becomes: <in remote pod>$ tar xf - -C /tmp Meaning that we first change directory to "/tmp" before extracting the contents specified into the current working directory, using the original source filename "test". So you end up with a new file in the pod "/tmp/test". or [Example 2] Local Source File: "test" Destination: "mypod:/tmp" Becomes: <in remote pod>$ tar xf - -c / Meaning that we first change directory to "/" before extracting the contents into it using the original source name "test". Since we cannot create a new file named "test" in the root directory of the pod, we end up with the error: "tar: can't open 'test': Permission denied" A recent PR (https://github.com/openshift/origin/pull/15929) aims to update the copy command, such that the name you specify in your destination path is actually used. For example, given the following: Local Source File: "test" Destination: "mypod:/tmp/mycustomname" You would copy the local file "test" under a new file "/tmp/mycustomname" in the remote pod (right now, the file gets copied under "/tmp/test" in the pod, and "mycustomname" is ignored). With this in mind, I could update the existing PR (15929) to additionally check for a trailing "/" in the destination path, such that if you have the following: Local Source File: "test" Destination: "mypod:/tmp/" The current behavior of using the Local Source File name is kept. So you would end up with a new file "/tmp/test" in the remote pod. Because the command does not check if "tmp" already exists and is a directory in the remote pod, without a trailing "/", [Example 2] with the updated `oc cp` command (with patch 15929 applied) would now give the error "tar: tmp: Cannot open: File exists", meaning that in the root directory, there is already a file or directory named "tmp" (your chosen destination) and therefore is unable to proceed. This has been addressed by two related upstream PRs: - https://github.com/kubernetes/kubernetes/pull/51215 - https://github.com/kubernetes/kubernetes/pull/52465 Marking as UpcomingRelease Like bug 1469411, this bug is fixed in v3.9, pls help move to ON_QA, thanks Verified on oc v3.9.0-0.16.0 For step3: $ oc cp test1 mypod:/tmp/ $ oc rsh mypod ls /tmp test1 For step2: $ oc cp test2 mypod:/tmp $ oc rsh mypod ls /tmp test1 test2 |