From 4954dc9e0633c5d2a0b127f9987efd5446c6c49e Mon Sep 17 00:00:00 2001 From: Anusha Ragunathan Date: Thu, 22 Sep 2016 18:20:39 -0700 Subject: [PATCH] Call "VolumeDriver.Unmount" during container stop. "VolumeDriver.Mount" is being called on container start. Make the symmetric call on container stop. Signed-off-by: Anusha Ragunathan Upstream-commit: d576509d8ad1ef4770cb3959a792748c8658b0be Component: engine --- .../engine/container/container_windows.go | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/components/engine/container/container_windows.go b/components/engine/container/container_windows.go index 0a6c7a8ff8..7d1a7037f7 100644 --- a/components/engine/container/container_windows.go +++ b/components/engine/container/container_windows.go @@ -49,6 +49,40 @@ func (container *Container) IpcMounts() []Mount { // UnmountVolumes explicitly unmounts volumes from the container. func (container *Container) UnmountVolumes(forceSyscall bool, volumeEventLog func(name, action string, attributes map[string]string)) error { + var ( + volumeMounts []volume.MountPoint + err error + ) + + for _, mntPoint := range container.MountPoints { + dest, err := container.GetResourcePath(mntPoint.Destination) + if err != nil { + return err + } + volumeMounts = append(volumeMounts, volume.MountPoint{Destination: dest, Volume: mntPoint.Volume, ID: mntPoint.ID}) + + } + + // atm, this is a no-op. + if volumeMounts, err = appendNetworkMounts(container, volumeMounts); err != nil { + return err + } + + for _, volumeMount := range volumeMounts { + if volumeMount.Volume != nil { + if err := volumeMount.Volume.Unmount(volumeMount.ID); err != nil { + return err + } + volumeMount.ID = "" + + attributes := map[string]string{ + "driver": volumeMount.Volume.DriverName(), + "container": container.ID, + } + volumeEventLog(volumeMount.Volume.Name(), "unmount", attributes) + } + } + return nil }