add remount logic if original mount path is invalid

pull/6/head
andyzhangx 2018-01-08 06:01:42 +00:00
parent 9f80ae7410
commit 1bfb5d0670
2 changed files with 26 additions and 2 deletions

View File

@ -232,6 +232,19 @@ func (attacher *azureDiskAttacher) MountDevice(spec *volume.Spec, devicePath str
}
}
if !notMnt {
// testing original mount point, make sure the mount link is valid
if _, err := (&osIOHandler{}).ReadDir(deviceMountPath); err != nil {
// mount link is invalid, now unmount and remount later
glog.Warningf("azureDisk - ReadDir %s failed with %v, unmount this directory", deviceMountPath, err)
if err := mounter.Unmount(deviceMountPath); err != nil {
glog.Errorf("azureDisk - Unmount deviceMountPath %s failed with %v", deviceMountPath, err)
return err
}
notMnt = true
}
}
volumeSource, err := getVolumeSource(spec)
if err != nil {
return err

View File

@ -86,8 +86,19 @@ func (m *azureDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
return err
}
if !mountPoint {
glog.V(4).Infof("azureDisk - already mounted to target %s", dir)
return nil
// testing original mount point, make sure the mount link is valid
_, err := (&osIOHandler{}).ReadDir(dir)
if err == nil {
glog.V(4).Infof("azureDisk - already mounted to target %s", dir)
return nil
}
// mount link is invalid, now unmount and remount later
glog.Warningf("azureDisk - ReadDir %s failed with %v, unmount this directory", dir, err)
if err := mounter.Unmount(dir); err != nil {
glog.Errorf("azureDisk - Unmount directory %s failed with %v", dir, err)
return err
}
mountPoint = true
}
if runtime.GOOS != "windows" {