mirror of
https://github.com/clearlinux/docker.git
synced 2026-10-03 23:38:24 +00:00
runtime test: Ensure all containers are unmounted at nuke()
Otherwise we may leave around e.g. devmapper mounts
This commit is contained in:
committed by
Tianon Gravi
parent
a7e876e357
commit
b0a9147fd5
@@ -1181,6 +1181,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