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

Fixed mounting with containerized kubelet #23435

Merged

Conversation

jsafrane
Copy link
Member

NsenterMounter.IsLikelyNotMountPoint() should return ErrNotExist when the
checked directory does not exists - the regular mounted does this and
some volume plugins depend on this behavior.

See for example: https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/aws_ebs/aws_util.go#L72

Kubelet was not able to mount volumes when running inside a container and
using nsenter mounter,

NsenterMounter.IsLikelyNotMountPoint() should return ErrNotExist when the
checked directory does not exists as the regular mounted does this and
some volume plugins depend on this behavior.
@jsafrane
Copy link
Member Author

@kubernetes/sig-storage @kubernetes/rh-storage

@k8s-github-robot
Copy link

Labelling this PR as size/XS

@k8s-github-robot k8s-github-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Mar 24, 2016
@pmorie
Copy link
Member

pmorie commented Mar 24, 2016

@jsafrane what does findmnt return when you give it a target that doesn't exist?

@luxas
Copy link
Member

luxas commented Mar 24, 2016

ping @fgrzadkowski
ref: #21486

@jsafrane
Copy link
Member Author

findmnt just returns exit status 1, I don't think we should depend on that.

@pmorie
Copy link
Member

pmorie commented Mar 24, 2016

@jsafrane I get it now.

@@ -170,6 +170,12 @@ func (n *NsenterMounter) IsLikelyNotMountPoint(file string) (bool, error) {
return true, err
}

// Check the directory exists
if _, err = os.Stat(file); os.IsNotExist(err) {
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 going to run in the container's mount namespace -- don't we need to do this check in the host's mount ns?

Copy link
Member Author

Choose a reason for hiding this comment

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

Kubernetes runs with /var/lib/kubernetes mounted to the same directory in the container so it works.

If you look e.g. into AWS volume plugin, it just calls mkdir() there without any nsenter. https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/aws_ebs/aws_util.go#L75

Copy link
Member

Choose a reason for hiding this comment

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

Isn't it /var/lib/kubelet?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's imagine we have a directory /var/lib/kubelet/test which is a mount point which contains directory foo. Now, I think that if we call IsLikelyNotMountPoint for it var/lib/kubelet/test/foo we'd get false for newer versions of findmnt (see comment in line 186). If that's the case (I haven't tested this) your change would introduce a semantic change as now we'd return true.

I'm not saying it's a bad change, but we should say it explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, it's /var/lib/kubelet, sorry.

@fgrzadkowski, I don't understand your point. If var/lib/kubelet/test/foo exist, this patch does not change a thing. Only if it doesn't we return ErrNotExist to tell the caller to create the directory before mounting.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. The change only affects the situation when the directory does not exist. I just want to make sure we are clear about semantics.

Copy link
Member

Choose a reason for hiding this comment

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

@fgrzadkowski Personally I think this change is correct, and that the semantics are clear. Prior to this patch it is ambiguous how the dir-doesn't-exist case is handled; this makes nsenter_mount.go consistent with mount.go and documents the semantics.

@k8s-bot
Copy link

k8s-bot commented Mar 24, 2016

GCE e2e build/test passed for commit 92f1811.

@ghost
Copy link

ghost commented Apr 5, 2016

This LGTM.. @pmorie are there outstanding issues here ?

@rootfs
Copy link
Contributor

rootfs commented Apr 5, 2016

LGTM

@pmorie pmorie assigned pmorie and unassigned thockin Apr 5, 2016
@pmorie pmorie added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed cla: yes labels Apr 5, 2016
@k8s-github-robot
Copy link

@k8s-bot test this

Tests are more than 48 hours old. Re-running tests.

@k8s-github-robot
Copy link

Removing LGTM because the release note process has not been followed.
One of the following labels is required "release-note", "release-note-none", or "release-note-action-required"
Please see: https://github.com/kubernetes/kubernetes/blob/master/docs/proposals/release-notes.md

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 5, 2016
@pmorie pmorie added the release-note-none Denotes a PR that doesn't merit a release note. label Apr 5, 2016
@k8s-bot
Copy link

k8s-bot commented Apr 5, 2016

GCE e2e build/test passed for commit 92f1811.

@pmorie pmorie added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 5, 2016
@luxas
Copy link
Member

luxas commented Apr 5, 2016

Have you tested this code on platforms that do not have findmnt on hosts like RancherOS?

@pmorie
Copy link
Member

pmorie commented Apr 5, 2016

@luxas we haven't -- this code has always used findmnt, so this PR does not change anything from a dependency standpoint.

@pmorie
Copy link
Member

pmorie commented Apr 5, 2016

@k8s-bot test this issue: #23873

@jsafrane
Copy link
Member Author

jsafrane commented Apr 8, 2016

@k8s-bot test this issue: #24031

@k8s-bot
Copy link

k8s-bot commented Apr 8, 2016

GCE e2e build/test passed for commit 92f1811.

@k8s-github-robot
Copy link

@k8s-bot test this

Tests are more than 48 hours old. Re-running tests.

@k8s-bot
Copy link

k8s-bot commented Apr 10, 2016

GCE e2e build/test passed for commit 92f1811.

@k8s-github-robot
Copy link

@k8s-bot test this

Tests are more than 48 hours old. Re-running tests.

@k8s-bot
Copy link

k8s-bot commented Apr 12, 2016

GCE e2e build/test passed for commit 92f1811.

@eparis eparis added this to the v1.3 milestone Apr 13, 2016
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

@k8s-bot test this issue: #IGNORE

Tests have been pending for 24 hours

@k8s-bot
Copy link

k8s-bot commented Apr 13, 2016

GCE e2e build/test passed for commit 92f1811.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit ae57644 into kubernetes:master Apr 13, 2016
@k8s-bot
Copy link

k8s-bot commented Apr 13, 2016

GCE e2e build/test passed for commit 92f1811.

@ncdc
Copy link
Member

ncdc commented Apr 13, 2016

@kubernetes/sig-storage should we consider this a cherry-pick candidate for 1.2.x?

@jsafrane
Copy link
Member Author

@ncdc Done: #24244

Someone please label this PR as cherrypick-candidate, I don't have enough power for that.

@eparis eparis modified the milestones: v1.2, v1.3 Apr 14, 2016
@saad-ali
Copy link
Member

Is release-note-none appropriate here? If it is being cherry-picked don't we want it to show up in the next release notes?

@ncdc
Copy link
Member

ncdc commented Apr 15, 2016

@saad-ali yes, I'll flip it to release-note

@ncdc ncdc 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 Apr 15, 2016
@roberthbailey roberthbailey added the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Apr 18, 2016
zmerlynn added a commit that referenced this pull request Apr 20, 2016
…35-upstream-release-1.2

Automated cherry pick of #23435
@jsafrane jsafrane deleted the devel/fix-nsenter-mkdir branch August 19, 2016 11:09
shyamjvs pushed a commit to shyamjvs/kubernetes that referenced this pull request Dec 1, 2016
…ck-of-#23435-upstream-release-1.2

Automated cherry pick of kubernetes#23435
shouhong pushed a commit to shouhong/kubernetes that referenced this pull request Feb 14, 2017
…ck-of-#23435-upstream-release-1.2

Automated cherry pick of kubernetes#23435
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. 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.