From 1479fdcf8c162cb9b0c54673fedba2a2ee2dbf36 Mon Sep 17 00:00:00 2001
From: jingrui <jingrui@huawei.com>
Date: Wed, 14 Aug 2019 10:35:30 +0800
Subject: [PATCH 1/3] docker: hot-upgrade support default runtime

When hot-upgrade from docker-1.11.2, old version docker using
default runtime for runc. We need support start container created from
old version docker.

Change-Id: I1287c5a6798be57c8d0446230806dc87c98ab787
Signed-off-by: jingrui <jingrui@huawei.com>
---
 components/engine/daemon/config/config_common_unix.go | 5 +++++
 components/engine/daemon/daemon.go                    | 5 ++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/components/engine/daemon/config/config_common_unix.go b/components/engine/daemon/config/config_common_unix.go
index 0a862d3b50..e2dfec91bb 100644
--- a/components/engine/daemon/config/config_common_unix.go
+++ b/components/engine/daemon/config/config_common_unix.go
@@ -32,6 +32,11 @@ func (conf *Config) GetRuntime(name string) *types.Runtime {
 	if rt, ok := conf.Runtimes[name]; ok {
 		return &rt
 	}
+	if name == "default" { // legacy docker reserved default for runc.
+		if rt, ok := conf.Runtimes["runc"]; ok {
+			return &rt
+		}
+	}
 	return nil
 }
 
diff --git a/components/engine/daemon/daemon.go b/components/engine/daemon/daemon.go
index b9af915ef8..3bd0d93a52 100644
--- a/components/engine/daemon/daemon.go
+++ b/components/engine/daemon/daemon.go
@@ -357,13 +357,12 @@ func (daemon *Daemon) restore() error {
 			}).Debug("restoring container")
 
 			var (
-				err      error
-				alive    bool
 				ec       uint32
 				exitedAt time.Time
 			)
 
-			alive, _, err = daemon.containerd.Restore(context.Background(), c.ID, c.InitializeStdio)
+			alive, pid, err := daemon.containerd.Restore(context.Background(), c.ID, c.InitializeStdio)
+			logrus.Infof("restored %s from containerd alive=%t pid=%d error=%v", c.ID, alive, pid, err)
 			if err != nil && !errdefs.IsNotFound(err) {
 				logrus.Errorf("Failed to restore container %s with containerd: %s", c.ID, err)
 				return
-- 
2.17.1

