mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 02:34:03 +00:00
handle failed mounts for fc volumes
This commit is contained in:
parent
6a0d3c7494
commit
c02aeb7ec1
@ -36,7 +36,6 @@ type diskManager interface {
|
|||||||
// utility to mount a disk based filesystem
|
// utility to mount a disk based filesystem
|
||||||
func diskSetUp(manager diskManager, b fcDiskMounter, volPath string, mounter mount.Interface, fsGroup *int64) error {
|
func diskSetUp(manager diskManager, b fcDiskMounter, volPath string, mounter mount.Interface, fsGroup *int64) error {
|
||||||
globalPDPath := manager.MakeGlobalPDName(*b.fcDisk)
|
globalPDPath := manager.MakeGlobalPDName(*b.fcDisk)
|
||||||
// TODO: handle failed mounts here.
|
|
||||||
noMnt, err := mounter.IsLikelyNotMountPoint(volPath)
|
noMnt, err := mounter.IsLikelyNotMountPoint(volPath)
|
||||||
|
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
@ -57,7 +56,30 @@ func diskSetUp(manager diskManager, b fcDiskMounter, volPath string, mounter mou
|
|||||||
}
|
}
|
||||||
err = mounter.Mount(globalPDPath, volPath, "", options)
|
err = mounter.Mount(globalPDPath, volPath, "", options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("failed to bind mount:%s", globalPDPath)
|
glog.Errorf("Failed to bind mount: source:%s, target:%s, err:%v", globalPDPath, volPath, err)
|
||||||
|
noMnt, mntErr := b.mounter.IsLikelyNotMountPoint(volPath)
|
||||||
|
if mntErr != nil {
|
||||||
|
glog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !noMnt {
|
||||||
|
if mntErr = b.mounter.Unmount(volPath); mntErr != nil {
|
||||||
|
glog.Errorf("Failed to unmount: %v", mntErr)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
noMnt, mntErr = b.mounter.IsLikelyNotMountPoint(volPath)
|
||||||
|
if mntErr != nil {
|
||||||
|
glog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !noMnt {
|
||||||
|
// will most likely retry on next sync loop.
|
||||||
|
glog.Errorf("%s is still mounted, despite call to unmount(). Will try again next sync loop.", volPath)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os.Remove(volPath)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user