ソースを参照

runtime test: Ensure all containers are unmounted at nuke()

Otherwise we may leave around e.g. devmapper mounts
Alexander Larsson 11 年 前
コミット
67788723c9
2 ファイル変更13 行追加0 行削除
  1. 9 0
      container.go
  2. 4 0
      runtime_test.go

+ 9 - 0
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 {

+ 4 - 0
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)
 }