From 806f12804bb2c7382b9aa75882d70ec70c5e1b02 Mon Sep 17 00:00:00 2001 From: Josh Lothian Date: Wed, 22 Mar 2017 10:12:57 -0500 Subject: [PATCH] Fix docker restart in atomic In atomic, containers are left running when docker is restarted. When docker is restarted after the flannel config is put in place, the docker0 interface isn't re-IPed because docker sees the running containers and won't update the previous config. This patch kills all the running containers after docker is stopped. We can't simply `docker stop` the running containers, as they respawn before we've got a chance to stop the docker daemon, so we need to use runc to do this after dockerd is stopped. --- roles/network_plugin/flannel/handlers/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/roles/network_plugin/flannel/handlers/main.yml b/roles/network_plugin/flannel/handlers/main.yml index 98c93a53a..9a87e2ec2 100644 --- a/roles/network_plugin/flannel/handlers/main.yml +++ b/roles/network_plugin/flannel/handlers/main.yml @@ -10,6 +10,7 @@ - Flannel | reload systemd - Flannel | reload docker.socket - Flannel | reload docker + - Flannel | reload docker (atomic) - Flannel | pause while Docker restarts - Flannel | wait for docker @@ -26,6 +27,11 @@ service: name: docker state: restarted + when: not is_atomic + +- name: Flannel | reload docker (atomic) + shell: systemctl stop docker && runc list | awk '!/ID/ {print $1}' | xargs -n 1 -I ID runc kill ID KILL && systemctl start docker + when: is_atomic - name: Flannel | pause while Docker restarts pause: