Fix unmount issue cuased by GCI mounter

this is a workaround for the unmount device issue caused by gci mounter. In GCI cluster, if gci mounter is used for mounting, the container started by mounter script will cause additional mounts created in the container. Since these mounts are irrelavant to the original mounts, they should be not considered when checking the mount references. By comparing the mount path prefix, those additional mounts can be filtered out.

Plan to work on better approach to solve this issue.
This commit is contained in:
Jing Xu 2016-12-05 14:52:09 -08:00
parent 3a1cf2d52a
commit 896e0b867e
3 changed files with 12 additions and 4 deletions

View File

@ -130,13 +130,21 @@ func GetMountRefs(mounter Interface, mountPath string) ([]string, error) {
} }
} }
// TODO: this is a workaround for the unmount device issue caused by gci mounter.
// In GCI cluster, if gci mounter is used for mounting, the container started by mounter
// script will cause additional mounts created in the container. Since these mounts are
// irrelavant to the original mounts, they should be not considered when checking the
// mount references. Current solution is to filter out those mount paths that contain
// the string of original mount path.
// Plan to work on better approach to solve this issue.
// Find all references to the device. // Find all references to the device.
var refs []string var refs []string
if deviceName == "" { if deviceName == "" {
glog.Warningf("could not determine device for path: %q", mountPath) glog.Warningf("could not determine device for path: %q", mountPath)
} else { } else {
for i := range mps { for i := range mps {
if mps[i].Device == deviceName && mps[i].Path != slTarget { if mps[i].Device == deviceName && !strings.Contains(mps[i].Path, slTarget) {
refs = append(refs, mps[i].Path) refs = append(refs, mps[i].Path)
} }
} }

View File

@ -98,7 +98,7 @@ func TestGetMountRefs(t *testing.T) {
{Device: "/dev/sdb", Path: "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd"}, {Device: "/dev/sdb", Path: "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd"},
{Device: "/dev/sdb", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd-in-pod"}, {Device: "/dev/sdb", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd-in-pod"},
{Device: "/dev/sdc", Path: "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd2"}, {Device: "/dev/sdc", Path: "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd2"},
{Device: "/dev/sdc", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod"}, {Device: "/dev/sdc", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod1"},
{Device: "/dev/sdc", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod2"}, {Device: "/dev/sdc", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod2"},
}, },
} }
@ -114,7 +114,7 @@ func TestGetMountRefs(t *testing.T) {
}, },
}, },
{ {
"/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod", "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod1",
[]string{ []string{
"/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod2", "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd2-in-pod2",
"/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd2", "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd2",

View File

@ -94,7 +94,7 @@ func UnmountPath(mountPath string, mounter mount.Interface) error {
return err return err
} }
if notMnt { if notMnt {
glog.V(4).Info("%q is unmounted, deleting the directory", mountPath) glog.V(4).Infof("%q is unmounted, deleting the directory", mountPath)
return os.Remove(mountPath) return os.Remove(mountPath)
} }
return nil return nil