From 8b5072b291ebf4ca1fb0e30f64f61b45304e1835 Mon Sep 17 00:00:00 2001 From: Josh Lothian Date: Thu, 30 Mar 2017 17:57:40 -0500 Subject: [PATCH] Reconfigure docker restart behavior on atomic Before restarting docker, instruct it to kill running containers when it restarts. Needs a second docker restart after we restore the original behavior, otherwise the next time docker is restarted by an operator, it will unexpectedly bring down all running containers. --- .../network_plugin/flannel/handlers/main.yml | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/roles/network_plugin/flannel/handlers/main.yml b/roles/network_plugin/flannel/handlers/main.yml index 9a87e2ec2..e3e937a1f 100644 --- a/roles/network_plugin/flannel/handlers/main.yml +++ b/roles/network_plugin/flannel/handlers/main.yml @@ -9,7 +9,9 @@ notify: - Flannel | reload systemd - Flannel | reload docker.socket + - Flannel | reconfigure docker restart behavior (atomic) - Flannel | reload docker + - Flannel | restore docker restart behavior (atomic) - Flannel | reload docker (atomic) - Flannel | pause while Docker restarts - Flannel | wait for docker @@ -23,14 +25,29 @@ state: restarted when: ansible_os_family in ['CoreOS', 'Container Linux by CoreOS'] +- name: Flannel | reconfigure docker restart behavior (atomic) + replace: + name: /etc/docker/daemon.json + regexp: '"live-restore":.*true' + replace: '"live-restore": false' + when: is_atomic + - name: Flannel | reload docker service: name: docker state: restarted - when: not is_atomic + +- name: Flannel | restore docker restart behavior (atomic) + replace: + name: /etc/docker/daemon.json + regexp: '"live-restore": false' + replace: '"live-restore": true' + when: 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 + service: + name: docker + state: restarted when: is_atomic - name: Flannel | pause while Docker restarts