Merge pull request #95456 from andyzhangx/windows-flush

fix azure disk data loss issue on Windows when unmount disk
This commit is contained in:
Kubernetes Prow Robot 2020-10-09 22:22:46 -07:00 committed by GitHub
commit fa15799f74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)