From f35010d2a6a17d404ca925d83ed5427824cd156c Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 19 Sep 2013 19:20:05 +0200 Subject: [PATCH] runtime test: Ensure all containers are unmounted at nuke() Otherwise we may leave around e.g. devmapper mounts Upstream-commit: 67788723c99cda8b41e5a488b988e2a72732d684 Component: engine --- components/engine/container.go | 9 +++++++++ components/engine/runtime_test.go | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/components/engine/container.go b/components/engine/container.go index 35cd11080f..f5f7d0ef80 100644 --- a/components/engine/container.go +++ b/components/engine/container.go @@ -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 { diff --git a/components/engine/runtime_test.go b/components/engine/runtime_test.go index ccdf4d9563..684ca005cd 100644 --- a/components/engine/runtime_test.go +++ b/components/engine/runtime_test.go @@ -44,6 +44,10 @@ func nuke(runtime *Runtime) error { }(container) } wg.Wait() + + for _, container := range runtime.List() { + container.EnsureUnmounted() + } return os.RemoveAll(runtime.root) }