Commit ae576441 authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #23435 from jsafrane/devel/fix-nsenter-mkdir

Automatic merge from submit-queue Fixed mounting with containerized kubelet `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
parents 8eb19c78 92f18117
...@@ -34,6 +34,7 @@ type Interface interface { ...@@ -34,6 +34,7 @@ type Interface interface {
// consistent. // consistent.
List() ([]MountPoint, error) List() ([]MountPoint, error)
// IsLikelyNotMountPoint determines if a directory is a mountpoint. // IsLikelyNotMountPoint determines if a directory is a mountpoint.
// It should return ErrNotExist when the directory does not exist.
IsLikelyNotMountPoint(file string) (bool, error) IsLikelyNotMountPoint(file string) (bool, error)
} }
......
...@@ -170,6 +170,12 @@ func (n *NsenterMounter) IsLikelyNotMountPoint(file string) (bool, error) { ...@@ -170,6 +170,12 @@ func (n *NsenterMounter) IsLikelyNotMountPoint(file string) (bool, error) {
return true, err 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} 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) glog.V(5).Infof("findmnt command: %v %v", nsenterPath, args)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment