mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
Merge pull request #52687 from mtanino/teardown-refactor
Automatic merge from submit-queue (batch tested with PRs 51902, 52718, 52687, 52137, 52697). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.. Refactoring and improvements for iSCSI and FC storage plugins **What this PR does / why we need it**: This PR makes following changes. - Simplify volume tearDown path for iSCSI and FC using util.UnmountPath(). - Log lastErr during iscsi connection If iscsid fails to connect second portal, currently the error is ignored silently. The lastErr should be logged to find the root cause of problem. - Remove iscsi plugin directory after iscsi connection is successfully closed. **Which issue this PR fixes** : No related issues. **Special notes for your reviewer**: /cc @rootfs @jsafrane **Release note**: ``` NONE ```
This commit is contained in:
@@ -89,33 +89,3 @@ func diskSetUp(manager diskManager, b fcDiskMounter, volPath string, mounter mou
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// utility to tear down a disk based filesystem
|
||||
func diskTearDown(manager diskManager, c fcDiskUnmounter, volPath string, mounter mount.Interface) error {
|
||||
noMnt, err := mounter.IsLikelyNotMountPoint(volPath)
|
||||
if err != nil {
|
||||
glog.Errorf("cannot validate mountpoint %s", volPath)
|
||||
return err
|
||||
}
|
||||
if noMnt {
|
||||
return os.Remove(volPath)
|
||||
}
|
||||
|
||||
if err := mounter.Unmount(volPath); err != nil {
|
||||
glog.Errorf("failed to unmount %s", volPath)
|
||||
return err
|
||||
}
|
||||
|
||||
noMnt, mntErr := mounter.IsLikelyNotMountPoint(volPath)
|
||||
if mntErr != nil {
|
||||
glog.Errorf("isMountpoint check failed: %v", mntErr)
|
||||
return err
|
||||
}
|
||||
if noMnt {
|
||||
if err := os.Remove(volPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
@@ -243,13 +243,7 @@ func (c *fcDiskUnmounter) TearDown() error {
|
||||
}
|
||||
|
||||
func (c *fcDiskUnmounter) TearDownAt(dir string) error {
|
||||
if pathExists, pathErr := util.PathExists(dir); pathErr != nil {
|
||||
return fmt.Errorf("Error checking if path exists: %v", pathErr)
|
||||
} else if !pathExists {
|
||||
glog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir)
|
||||
return nil
|
||||
}
|
||||
return diskTearDown(c.manager, *c, dir, c.mounter)
|
||||
return util.UnmountPath(dir, c.mounter)
|
||||
}
|
||||
|
||||
func getVolumeSource(spec *volume.Spec) (*v1.FCVolumeSource, bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user