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

mountpath should be absolute #48815

Merged

Conversation

dixudx
Copy link
Member

@dixudx dixudx commented Jul 12, 2017

What this PR does / why we need it:
Should validate the mountpath before mounting to container. Docker forbids mounting to a relative path inside the container.

Which issue this PR fixes : fixes #48749

Special notes for your reviewer:

Release note:

MountPath should be absolute

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 12, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @dixudx. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jul 12, 2017
@@ -3045,7 +3045,6 @@ func TestValidateVolumeMounts(t *testing.T) {
{Name: "abc-123", MountPath: "/bab", SubPath: "baz"},
{Name: "abc-123", MountPath: "/bac", SubPath: ".baz"},
{Name: "abc-123", MountPath: "/bad", SubPath: "..baz"},
{Name: "abc", MountPath: "c:/foo/bar"},
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this absolute on a Windows machine?

Copy link
Member Author

Choose a reason for hiding this comment

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

@sttts It's true. Apiserver can be run on various OS/Arch. Currently all the CIs are running on Linux. Such windows-like absolute path "c:/foo/bar" is considered as relative path on Linux.

@@ -1760,6 +1760,9 @@ func ValidateVolumeMounts(mounts []api.VolumeMount, volumes sets.String, fldPath
if mountpoints.Has(mnt.MountPath) {
allErrs = append(allErrs, field.Invalid(idxPath.Child("mountPath"), mnt.MountPath, "must be unique"))
}
if !path.IsAbs(mnt.MountPath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens today if you use a non-absolute path? is it relative to the container root?

Copy link
Member Author

Choose a reason for hiding this comment

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

@sttts From the Docker Official Doc,

The container-dir must always be an absolute path such as /src/docs.

So the container cannot be started up if you use a non-absolute path for mnt.MountPath, just as what was reported in #48749.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ic. I was worried that we disallow something in the API that used to work.

/cc @derekwaynecarr sounds reasonable. ptal.

@sttts sttts assigned derekwaynecarr and unassigned sttts and thockin Jul 13, 2017
@sttts
Copy link
Contributor

sttts commented Jul 13, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 13, 2017
@thockin
Copy link
Member

thockin commented Jul 13, 2017

ISTR fixing this in the past, but it must have been something else related. Shame on me.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 13, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dixudx, thockin

Associated issue: 48749

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 13, 2017
@dixudx
Copy link
Member Author

dixudx commented Jul 13, 2017

/retest

1 similar comment
@dixudx
Copy link
Member Author

dixudx commented Jul 14, 2017

/retest

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 48082, 48815, 48901, 48824)

@k8s-github-robot k8s-github-robot merged commit a014cea into kubernetes:master Jul 14, 2017
@dixudx dixudx deleted the mountpath_should_be_absolute branch July 16, 2017 06:11
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.

MountPath inside container should be an absolute path
6 participants