runtime test: Ensure all containers are unmounted at nuke()
Otherwise we may leave around e.g. devmapper mounts Upstream-commit: 67788723c99cda8b41e5a488b988e2a72732d684 Component: engine
This commit is contained in:
committed by
Victor Vieux
parent
d224af31e1
commit
f35010d2a6
@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user