mirror of
https://github.com/docker/cli.git
synced 2026-01-18 08:21:31 +03:00
runtime test: Ensure all containers are unmounted at nuke()
Otherwise we may leave around e.g. devmapper mounts Upstream-commit: b0a9147fd5f0197931b73e18163a12b04ad8e826 Component: engine
This commit is contained in:
committed by
Tianon Gravi
parent
c5a71d7b11
commit
5fc36fa5bf
@@ -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