Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cp arg expansion bug in cloning implementation #82

Merged
merged 1 commit into from
Aug 1, 2019

Conversation

j-griffith
Copy link

@j-griffith j-griffith commented Jul 31, 2019

What type of PR is this?

bug

What this PR does / why we need it:

The clone implementation is just using cp /* can result in trying to actually find/copy a file named *. The result in some container images is a stat error for no such file or directory. Instead we should be using the cp notation of /. so we're portable and always work.

Which issue(s) this PR fixes:

Fixes #81

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Fixes cp expansion issue for volume cloning.

The cloning implementation for hostpath volumes used `args :=
[]string{"-a", srcPath + "/*", destPath + "/"}`

The result is some shells will actually try to find/copy a file `*` from
the source directory.  We need to use the cp specific syntax for this
instead `.`, to guarantee that things work on different platforms and
shells.
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 31, 2019
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jul 31, 2019
@j-griffith
Copy link
Author

/assign @msau42

@@ -293,7 +293,7 @@ func loadFromVolume(srcVolumeId, destPath string) error {

// If the source hostpath volume is empty it's a noop and we just move along, otherwise the cp call will fail with a a file stat error DNE
if !isEmpty {
args := []string{"-a", srcPath + "/*", destPath + "/"}
args := []string{"-a", srcPath + "/.", destPath + "/"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need -R?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, -a is the equivalent of -dR

@msau42
Copy link
Collaborator

msau42 commented Aug 1, 2019

/lgtm
/approve
/retest

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 1, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: j-griffith, msau42

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 1, 2019
@k8s-ci-robot k8s-ci-robot merged commit 0df74ce into kubernetes-csi:master Aug 1, 2019
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Aug 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using * in cp commands is a bad idea
3 participants