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
This commit is contained in:
Damien Ciabrini 2019-10-17 15:40:18 +02:00
parent 2b745412c4
commit ae453229a8

View File

@ -247,6 +247,9 @@ outputs:
systemd: systemd:
name: docker name: docker
register: docker_service_state register: docker_service_state
- name: Run docker system prune - name: Run docker image prune
shell: docker system prune -a -f 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' when: docker_service_state.status['SubState'] == 'running'