From 92f181174b849aa131a96b78fab6c7cdfc41e2c8 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Thu, 24 Mar 2016 17:27:11 +0100 Subject: [PATCH] Fixed mounting with containerized kubelet. 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. --- pkg/util/mount/mount.go | 1 + pkg/util/mount/nsenter_mount.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/pkg/util/mount/mount.go b/pkg/util/mount/mount.go index 79f3f6ec245..8f0489a3c3e 100644 --- a/pkg/util/mount/mount.go +++ b/pkg/util/mount/mount.go @@ -34,6 +34,7 @@ type Interface interface { // consistent. List() ([]MountPoint, error) // IsLikelyNotMountPoint determines if a directory is a mountpoint. + // It should return ErrNotExist when the directory does not exist. IsLikelyNotMountPoint(file string) (bool, error) } diff --git a/pkg/util/mount/nsenter_mount.go b/pkg/util/mount/nsenter_mount.go index 7c4ed261c80..0e8a7dcc043 100644 --- a/pkg/util/mount/nsenter_mount.go +++ b/pkg/util/mount/nsenter_mount.go @@ -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) { + glog.V(5).Infof("findmnt: directory %s does not exist", file) + return true, err + } + args := []string{"--mount=/rootfs/proc/1/ns/mnt", "--", n.absHostPath("findmnt"), "-o", "target", "--noheadings", "--target", file} glog.V(5).Infof("findmnt command: %v %v", nsenterPath, args)