Merge branch 'migrate-aufs-containers' into v0.7-rc3
Conflicts:
runtime.go
diff --git a/runtime.go b/runtime.go
index 70a4014..0a17bfd 100644
--- a/runtime.go
+++ b/runtime.go
@@ -327,31 +327,48 @@
// Perform a migration for aufs containers
if !deviceSet.HasDevice(container.ID) {
- utils.Debugf("[migration] Begin migration of %s", container.ID)
-
- image, err := runtime.graph.Get(container.Image)
+ contents, err := ioutil.ReadDir(container.rwPath())
if err != nil {
- utils.Debugf("[migratoin] Failed to get image %s", err)
- continue
- }
- if err := image.Mount(runtime, container.RootfsPath(), container.rwPath(), container.ID); err != nil {
- utils.Debugf("[migratoin] Failed to mount image %s", err)
+ if !os.IsNotExist(err) {
+ utils.Debugf("[migration] Error reading rw dir %s", err)
+ }
continue
}
- if err := image.applyLayer(container.rwPath(), container.RootfsPath()); err != nil {
- utils.Debugf("[migration] Failed to apply layer %s", err)
- }
+ if len(contents) > 0 {
+ utils.Debugf("[migration] Begin migration of %s", container.ID)
- if err := image.Unmount(runtime, container.RootfsPath(), container.ID); err != nil {
- utils.Debugf("[migraton] Failed to unmount image %s", err)
- }
+ image, err := runtime.graph.Get(container.Image)
+ if err != nil {
+ utils.Debugf("[migratoin] Failed to get image %s", err)
+ continue
+ }
- if err := os.RemoveAll(container.rwPath()); err != nil {
- utils.Debugf("[migration] Failed to remove rw dir %s", err)
- }
+ unmount := func() {
+ if err := image.Unmount(runtime, container.RootfsPath(), container.ID); err != nil {
+ utils.Debugf("[migraton] Failed to unmount image %s", err)
+ }
+ }
- utils.Debugf("[migration] End migration of %s", container.ID)
+ if err := image.Mount(runtime, container.RootfsPath(), container.rwPath(), container.ID); err != nil {
+ utils.Debugf("[migratoin] Failed to mount image %s", err)
+ continue
+ }
+
+ if err := image.applyLayer(container.rwPath(), container.RootfsPath()); err != nil {
+ utils.Debugf("[migration] Failed to apply layer %s", err)
+ unmount()
+ continue
+ }
+
+ unmount()
+
+ if err := os.RemoveAll(container.rwPath()); err != nil {
+ utils.Debugf("[migration] Failed to remove rw dir %s", err)
+ }
+
+ utils.Debugf("[migration] End migration of %s", container.ID)
+ }
}
if err := runtime.Register(container); err != nil {