fix azure disk data loss issue on Windows

This commit is contained in:
andyzhangx 2020-10-10 02:20:49 +00:00
parent fb3e2c42ef
commit 9e35244c6c

View File

@ -285,6 +285,15 @@ func (d *azureDiskDetacher) Detach(diskURI string, nodeName types.NodeName) erro
// UnmountDevice unmounts the volume on the node // UnmountDevice unmounts the volume on the node
func (d *azureDiskDetacher) UnmountDevice(deviceMountPath string) error { func (d *azureDiskDetacher) UnmountDevice(deviceMountPath string) error {
if runtime.GOOS == "windows" {
// Flush data cache for windows because it does not do so automatically during unmount device
exec := d.plugin.host.GetExec(d.plugin.GetPluginName())
err := util.WriteVolumeCache(deviceMountPath, exec)
if err != nil {
return err
}
}
err := mount.CleanupMountPoint(deviceMountPath, d.plugin.host.GetMounter(d.plugin.GetPluginName()), false) err := mount.CleanupMountPoint(deviceMountPath, d.plugin.host.GetMounter(d.plugin.GetPluginName()), false)
if err == nil { if err == nil {
klog.V(2).Infof("azureDisk - Device %s was unmounted", deviceMountPath) klog.V(2).Infof("azureDisk - Device %s was unmounted", deviceMountPath)