Less agressive cleanup of docker containers in post_upgrade_tasks

"system prune -a -f" deletes unused container images, as well as
containers which are stopped. This removes useful HA containers
*_init_bundle and *_restart_bundle, which makes debugging more
complex. This also removes tags whose image id are used by
pacemaker HA container.

Reduce the effect of cleanup by keeping stopped containers, which
in effect ensures that we also keep the tags used by HA containers.

Note: keep the aggressive cleanup for upgrade_tasks, because
they are always followed by deployed tasks, which recreate the
missing containers.

Note2: This doesn't apply for podman containers, whose cleanup
looks similar but is not as aggressive.

Change-Id: I936fb965687b961602e677bcca72f403121cbb0d
Closes-Bug: #1846368
(cherry picked from commit ae453229a8)
This commit is contained in:
Damien Ciabrini 2019-10-17 15:40:18 +02:00 committed by Carlos Camacho
parent 4e81c3ad57
commit 594662cc28
1 changed files with 5 additions and 2 deletions

View File

@ -247,6 +247,9 @@ outputs:
systemd:
name: docker
register: docker_service_state
- name: Run docker system prune
shell: docker system prune -a -f
- name: Run docker image prune
shell: docker image prune -f
when: docker_service_state.status['SubState'] == 'running'
- name: Run docker volume prune
shell: docker volume prune -f
when: docker_service_state.status['SubState'] == 'running'