From 9e35244c6c6b6a03139cfedf36e35dcb7f8df0f2 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Sat, 10 Oct 2020 02:20:49 +0000 Subject: [PATCH] fix azure disk data loss issue on Windows --- pkg/volume/azuredd/attacher.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/volume/azuredd/attacher.go b/pkg/volume/azuredd/attacher.go index 0a37fec958f..f5d84312c72 100644 --- a/pkg/volume/azuredd/attacher.go +++ b/pkg/volume/azuredd/attacher.go @@ -285,6 +285,15 @@ func (d *azureDiskDetacher) Detach(diskURI string, nodeName types.NodeName) erro // UnmountDevice unmounts the volume on the node 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) if err == nil { klog.V(2).Infof("azureDisk - Device %s was unmounted", deviceMountPath)