Pull and prune docker images together

We noticed that our zuul scheduler was running out of disk and one of
the causes of this is we are pulling all of the wonderful new zuul
images and not pruning them. This happens because we were only pruning
when (re)starting services and we don't do that automatically with Zuul.
Address this by always pruning after pulling even if we don't restart
services. This should be safe because prune will leave the latest tagged
images as well as the running images.

This should keep our disk consumption down.

Change-Id: Ibdd22ac42d86781f1e87c3d11e05fd8f99677167
This commit is contained in:
Clark Boylan 2020-05-07 08:52:48 -07:00
parent 351264c919
commit c0fd3e0894
9 changed files with 28 additions and 17 deletions

View File

@ -41,6 +41,10 @@
cmd: docker-compose up -d
chdir: /etc/nodepool-builder-compose/
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f
- name: Disable old service
service:
name: nodepool-builder

View File

@ -54,6 +54,12 @@
include_tasks: start.yaml
when: nodepool_launcher_start | bool
# We can prune here as it should leave the "latest" tagged images
# as well as the currently running images.
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f
- name: Disable old service
service:
name: nodepool-launcher

View File

@ -2,7 +2,3 @@
shell:
cmd: docker-compose up -d
chdir: /etc/nodepool-docker/
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f

View File

@ -51,6 +51,12 @@
include_tasks: start.yaml
when: zuul_merger_start | bool
# We can prune here as it should leave the "latest" tagged images
# as well as the currently running images.
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f
- name: Disable old service
service:
name: zuul-merger

View File

@ -2,7 +2,3 @@
shell:
cmd: docker-compose up -d
chdir: /etc/zuul-merger
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f

View File

@ -72,6 +72,12 @@
include_tasks: start.yaml
when: zuul_scheduler_start is defined and zuul_scheduler_start | bool
# We can prune here as it should leave the "latest" tagged images
# as well as the currently running images.
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f
- name: Disable old service
service:
name: zuul-scheduler

View File

@ -2,8 +2,3 @@
shell:
cmd: docker-compose up -d
chdir: /etc/zuul-scheduler
# TODO: put this in a handler
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f

View File

@ -100,6 +100,12 @@
include_tasks: start.yaml
when: zuul_web_start | bool
# We can prune here as it should leave the "latest" tagged images
# as well as the currently running images.
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f
- name: Disable old service
service:
name: 'zuul-{{ item }}'

View File

@ -2,7 +2,3 @@
shell:
cmd: docker-compose up -d
chdir: /etc/zuul-web
- name: Run docker prune to cleanup unneeded images
shell:
cmd: docker image prune -f