diff --git a/pkg/zfs/mount.go b/pkg/zfs/mount.go index 464b50bf3..a9b8c88b7 100644 --- a/pkg/zfs/mount.go +++ b/pkg/zfs/mount.go @@ -78,9 +78,8 @@ func UmountVolume(vol *apis.ZFSVolume, targetPath string, } } - if err := os.RemoveAll(targetPath); err != nil { + if err := os.Remove(targetPath); err != nil { logrus.Errorf("zfspv: failed to remove mount path Error: %v", err) - return err } logrus.Infof("umount done path %v", targetPath) diff --git a/pkg/zfs/zfs_util.go b/pkg/zfs/zfs_util.go index a00d6689e..c2c911bf7 100644 --- a/pkg/zfs/zfs_util.go +++ b/pkg/zfs/zfs_util.go @@ -422,8 +422,22 @@ func MountZFSDataset(vol *apis.ZFSVolume, mountpath string) error { // UmountZFSDataset umounts the dataset func UmountZFSDataset(vol *apis.ZFSVolume) error { volume := vol.Spec.PoolName + "/" + vol.Name + var MountVolArg []string + MountVolArg = append(MountVolArg, "umount", volume) + cmd := exec.Command(ZFSVolCmd, MountVolArg...) + out, err := cmd.CombinedOutput() + if err != nil { + logrus.Errorf("zfs: could not umount the dataset %v cmd %v error: %s", + volume, MountVolArg, string(out)) + return err + } + // ignoring the failure of setting the mountpoint to none + // as the dataset has already been umounted, now the new pod + // can mount it and it will change that to desired mountpath + // and try to mount it if not mounted + SetDatasetMountProp(volume, "none") - return SetDatasetMountProp(volume, "none") + return nil } // GetVolumeProperty gets zfs properties for the volume