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.
This commit is contained in:
Josh Lothian 2017-03-30 17:57:40 -05:00
parent 806f12804b
commit 8b5072b291

View file

@ -9,7 +9,9 @@
notify: notify:
- Flannel | reload systemd - Flannel | reload systemd
- Flannel | reload docker.socket - Flannel | reload docker.socket
- Flannel | reconfigure docker restart behavior (atomic)
- Flannel | reload docker - Flannel | reload docker
- Flannel | restore docker restart behavior (atomic)
- Flannel | reload docker (atomic) - Flannel | reload docker (atomic)
- Flannel | pause while Docker restarts - Flannel | pause while Docker restarts
- Flannel | wait for docker - Flannel | wait for docker
@ -23,14 +25,29 @@
state: restarted state: restarted
when: ansible_os_family in ['CoreOS', 'Container Linux by CoreOS'] 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 - name: Flannel | reload docker
service: service:
name: docker name: docker
state: restarted 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) - 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 when: is_atomic
- name: Flannel | pause while Docker restarts - name: Flannel | pause while Docker restarts