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 bug convert volume host path to absolute #3537

Merged
merged 1 commit into from
Jul 12, 2019

Conversation

QiWang19
Copy link
Contributor

@QiWang19 QiWang19 commented Jul 9, 2019

fix #3504 If --volume host:dest host is not a named volume, convert the host to a absolute directory path.

Signed-off-by: Qi Wang qiwan@redhat.com

@@ -663,6 +664,12 @@ func (config *CreateConfig) getVolumeMounts() (map[string]spec.Mount, map[string

if strings.HasPrefix(src, "/") || strings.HasPrefix(src, ".") {
// This is not a named volume
// convert src to an absolute path
src, err := filepath.Abs(src)
log.Println("src is , ", src)
Copy link
Member

Choose a reason for hiding this comment

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

This looks like debugging information.

Copy link
Member

Choose a reason for hiding this comment

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

Can you use source as the new variable, so we can refer back to src.

src, err := filepath.Abs(src)
log.Println("src is , ", src)
if err != nil {
return nil, nil, errors.Wrapf(err, "error getting absolute source path")
Copy link
Member

Choose a reason for hiding this comment

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

Could you wrap include the src directory.

@@ -663,10 +663,15 @@ func (config *CreateConfig) getVolumeMounts() (map[string]spec.Mount, map[string

if strings.HasPrefix(src, "/") || strings.HasPrefix(src, ".") {
// This is not a named volume
// convert src to an absolute path
source, err := filepath.Abs(src)
Copy link
Member

Choose a reason for hiding this comment

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

This is a bad place to handle things since it only hits the --volume flag and not --mount. Better place would be the loop at https://github.com/containers/libpod/blob/943c8daf6db1ec9995f0e7a8f1392c2d83dc4376/pkg/spec/storage.go#L203-L214 - after we check for tmpfs, check if it's a bind mount, and if it is do a filepath.Abs() on the source path.

@mheon
Copy link
Member

mheon commented Jul 10, 2019

/approve
Change LGTM

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mheon, QiWang19

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 10, 2019
@mheon
Copy link
Member

mheon commented Jul 10, 2019

Needs rebase to fix tests

fix containers#3504 If --volume host:dest host is not a named volume, convert the host to a absolute directory path.

Signed-off-by: Qi Wang <qiwan@redhat.com>
@QiWang19
Copy link
Contributor Author

@mheon rebased, PTAL

@mheon
Copy link
Member

mheon commented Jul 12, 2019

LGTM on my end. @vrothberg @giuseppe @rhatdan PTAL

@rhatdan
Copy link
Member

rhatdan commented Jul 12, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 12, 2019
@openshift-merge-robot openshift-merge-robot merged commit 62352b2 into containers:master Jul 12, 2019
@QiWang19 QiWang19 deleted the volumeabs branch June 26, 2020 15:11
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Volume mount of '.' uses internal directory
5 participants