1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

runtime test: Ensure all containers are unmounted at nuke()

Otherwise we may leave around e.g. devmapper mounts
This commit is contained in:
Alexander Larsson 2013-09-19 19:20:05 +02:00 committed by Victor Vieux
parent f99f39abaa
commit 67788723c9
2 changed files with 13 additions and 0 deletions

View file

@ -1180,6 +1180,15 @@ func (container *Container) EnsureMounted() error {
return container.Mount()
}
func (container *Container) EnsureUnmounted() error {
if mounted, err := container.Mounted(); err != nil {
return err
} else if !mounted {
return nil
}
return container.Unmount()
}
func (container *Container) Mount() error {
image, err := container.GetImage()
if err != nil {

View file

@ -44,6 +44,10 @@ func nuke(runtime *Runtime) error {
}(container)
}
wg.Wait()
for _, container := range runtime.List() {
container.EnsureUnmounted()
}
return os.RemoveAll(runtime.root)
}