From 7f2ade5b5acd8e19a7eecc8d83dd787bda5c9398 Mon Sep 17 00:00:00 2001
From: Jeffrey Zhang <zhang.lei.fly@gmail.com>
Date: Fri, 28 Jul 2017 10:03:03 +0800
Subject: [PATCH] Stop and start container rather than use restart directly

Docker has an issue[0] when restart container. But stop then start
works.

[0] https://github.com/moby/moby/issues/29704

Change-Id: If0a9c0c257cd72209be8e138a1f0b8871500e089
Closes-Bug: #1707097
---
 ansible/library/kolla_docker.py | 3 ++-
 tests/test_kolla_docker.py      | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py
index 728f0fd879..9ff4ead66e 100644
--- a/ansible/library/kolla_docker.py
+++ b/ansible/library/kolla_docker.py
@@ -669,7 +669,8 @@ class DockerWorker(object):
                 msg="No such container: {}".format(name))
         else:
             self.changed = True
-            self.dc.restart(name, timeout=graceful_timeout)
+            self.dc.stop(name, timeout=graceful_timeout)
+            self.dc.start(name)
 
     def create_volume(self):
         if not self.check_volume():
diff --git a/tests/test_kolla_docker.py b/tests/test_kolla_docker.py
index f1fa89fa38..7fb4015a01 100644
--- a/tests/test_kolla_docker.py
+++ b/tests/test_kolla_docker.py
@@ -298,7 +298,8 @@ class TestContainer(base.BaseTestCase):
         self.assertTrue(self.dw.changed)
         self.dw.dc.containers.assert_called_once_with(all=True)
         self.dw.dc.inspect_container.assert_called_once_with('my_container')
-        self.dw.dc.restart.assert_called_once_with('my_container', timeout=10)
+        self.dw.dc.stop.assert_called_once_with('my_container', timeout=10)
+        self.dw.dc.start.assert_called_once_with('my_container')
 
     def test_restart_container_not_exists(self):
         self.dw = get_DockerWorker({'name': 'fake-container',