func (detacher *rbdDetacher) UnmountDevice(deviceMountPath string) error {
	if pathExists, pathErr := mount.PathExists(deviceMountPath); pathErr != nil {
		return fmt.Errorf("error checking if path exists: %v", pathErr)
	} else if !pathExists {
		klog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath)
		return nil
	}
	devicePath, _, err := mount.GetDeviceNameFromMount(detacher.mounter, deviceMountPath)
	if err != nil {
		return err
	}
	// Unmount the device from the device mount point.
	notMnt, err := detacher.mounter.IsLikelyNotMountPoint(deviceMountPath)
	if err != nil {
		return err
	}
	if !notMnt {
		klog.V(4).Infof("rbd: unmouting device mountpoint %s", deviceMountPath)
		if err = detacher.mounter.Unmount(deviceMountPath); err != nil {
			return err
		}
		klog.V(3).Infof("rbd: successfully umount device mountpath %s", deviceMountPath)
	}

	// Get devicePath from deviceMountPath if devicePath is empty
	if devicePath == "" {
		rbdImageInfo, err := getRbdImageInfo(deviceMountPath)
		if err != nil {
			return err
		}
		found := false
		devicePath, found = getRbdDevFromImageAndPool(rbdImageInfo.pool, rbdImageInfo.name)
		if !found {
			klog.Warningf("rbd: can't found devicePath for %v. Device is already unmounted, Image %v, Pool %v", deviceMountPath, rbdImageInfo.pool, rbdImageInfo.name)
		}
	}

	if devicePath != "" {
		klog.V(4).Infof("rbd: detaching device %s", devicePath)
		err = detacher.manager.DetachDisk(detacher.plugin, deviceMountPath, devicePath)
		if err != nil {
			return err
		}
		klog.V(3).Infof("rbd: successfully detach device %s", devicePath)
	}
	err = os.Remove(deviceMountPath)
	if err != nil {
		return err
	}
	klog.V(3).Infof("rbd: successfully remove device mount point %s", deviceMountPath)
	return nil
}
// UnmountDevice implements Detacher.UnmountDevice. It unmounts the global
// mount of the RBD image. This is called once all bind mounts have been
// unmounted.
// Internally, it does four things:
//  - Unmount device from deviceMountPath.
//  - Detach device from the node.
//  - Remove lock if found. (No need to check volume readonly or not, because
//  device is not on the node anymore, it's safe to remove lock.)
//  - Remove the deviceMountPath at last.
// This method is idempotent, callers are responsible for retrying on failure.
UnmountDevice implements Detacher.UnmountDevice. It unmounts the global
mount of the RBD image. This is called once all bind mounts have been
unmounted.
Internally, it does four things:
- Unmount device from deviceMountPath.
- Detach device from the node.
- Remove lock if found. (No need to check volume readonly or not, because
device is not on the node anymore, it's safe to remove lock.)
- Remove the deviceMountPath at last.
This method is idempotent, callers are responsible for retrying on failure.
// UnmountDevice implements Detacher . UnmountDevice . It unmounts the global // mount of the RBD image . This is called once all bind mounts have been // unmounted . // Internally it does four things : // - Unmount device from deviceMountPath . // - Detach device from the node . // - Remove lock if found . ( No need to check volume readonly or not because // device is not on the node anymore it ' s safe to remove lock . ) // - Remove the deviceMountPath at last . // This method is idempotent callers are responsible for retrying on failure .
func (detacher *rbdDetacher) UnmountDevice(deviceMountPath string) error {
	if pathExists, pathErr := mount.PathExists(deviceMountPath); pathErr != nil {
		return fmt.Errorf("error checking if path exists: %v", pathErr)
	} else if !pathExists {
		klog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath)
		return nil
	}
	devicePath, _, err := mount.GetDeviceNameFromMount(detacher.mounter, deviceMountPath)
	if err != nil {
		return err
	}
	notMnt, err := detacher.mounter.IsLikelyNotMountPoint(deviceMountPath)
	if err != nil {
		return err
	}
	if !notMnt {
		klog.V(4).Infof("rbd: unmouting device mountpoint %s", deviceMountPath)
		if err = detacher.mounter.Unmount(deviceMountPath); err != nil {
			return err
		}
		klog.V(3).Infof("rbd: successfully umount device mountpath %s", deviceMountPath)
	}
	if devicePath == "" {
		rbdImageInfo, err := getRbdImageInfo(deviceMountPath)
		if err != nil {
			return err
		}
		found := false
		devicePath, found = getRbdDevFromImageAndPool(rbdImageInfo.pool, rbdImageInfo.name)
		if !found {
			klog.Warningf("rbd: can't found devicePath for %v. Device is already unmounted, Image %v, Pool %v", deviceMountPath, rbdImageInfo.pool, rbdImageInfo.name)
		}
	}
	if devicePath != "" {
		klog.V(4).Infof("rbd: detaching device %s", devicePath)
		err = detacher.manager.DetachDisk(detacher.plugin, deviceMountPath, devicePath)
		if err != nil {
			return err
		}
		klog.V(3).Infof("rbd: successfully detach device %s", devicePath)
	}
	err = os.Remove(deviceMountPath)
	if err != nil {
		return err
	}
	klog.V(3).Infof("rbd: successfully remove device mount point %s", deviceMountPath)
	return nil
}
func ( detacher * rbdDetacher ) UnmountDevice ( deviceMountPath string ) error { if pathExists , pathErr := mount . PathExists ( deviceMountPath ) ; pathErr != nil { return fmt . Errorf ( " " , pathErr ) } else if ! pathExists { klog . Warningf ( " " , deviceMountPath ) return nil } devicePath , _ , err := mount . GetDeviceNameFromMount ( detacher . mounter , deviceMountPath ) if err != nil { return err } notMnt , err := detacher . mounter . IsLikelyNotMountPoint ( deviceMountPath ) if err != nil { return err } if ! notMnt { klog . V ( 4 ) . Infof ( " " , deviceMountPath ) if err = detacher . mounter . Unmount ( deviceMountPath ) ; err != nil { return err } klog . V ( 3 ) . Infof ( " " , deviceMountPath ) } if devicePath == " " { rbdImageInfo , err := getRbdImageInfo ( deviceMountPath ) if err != nil { return err } found := false devicePath , found = getRbdDevFromImageAndPool ( rbdImageInfo . pool , rbdImageInfo . name ) if ! found { klog . Warningf ( " " , deviceMountPath , rbdImageInfo . pool , rbdImageInfo . name ) } } if devicePath != " " { klog . V ( 4 ) . Infof ( " " , devicePath ) err = detacher . manager . DetachDisk ( detacher . plugin , deviceMountPath , devicePath ) if err != nil { return err } klog . V ( 3 ) . Infof ( " " , devicePath ) } err = os . Remove ( deviceMountPath ) if err != nil { return err } klog . V ( 3 ) . Infof ( " " , deviceMountPath ) return nil }
UnmountDevice implements Detacher.UnmountDevice.
UnmountDevice implements Detacher . UnmountDevice .
// Unmount the device from the device mount point. // Get devicePath from deviceMountPath if devicePath is empty