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:
parent
f99f39abaa
commit
67788723c9
2 changed files with 13 additions and 0 deletions
|
@ -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 {
|
||||
|
|
|
@ -44,6 +44,10 @@ func nuke(runtime *Runtime) error {
|
|||
}(container)
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for _, container := range runtime.List() {
|
||||
container.EnsureUnmounted()
|
||||
}
|
||||
return os.RemoveAll(runtime.root)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue