aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDincer Celik <hello@dincercelik.com>2019-12-12 13:57:17 +0300
committerDincer Celik <hello@dincercelik.com>2020-01-27 13:44:01 +0300
commitb7728ea8907a6e7ccd7decf56d3fc7b0365619dd (patch)
tree623f83eac38b3c44f547c9ec9a2e657d9b477201
parentbcc09ed2b44972b483baf6b6db74181fab73dd65 (diff)
downloadkolla-ansible-b7728ea8907a6e7ccd7decf56d3fc7b0365619dd.tar.gz
kolla-ansible-b7728ea8907a6e7ccd7decf56d3fc7b0365619dd.zip
Adds Docker image pruning command
This change introduces prune-images command. Uses docker_prune module of Ansible that comes with version 2.8. Depends-On: https://review.opendev.org/#/c/699333/ Implements: blueprint docker-image-pruning Change-Id: Icbf374dd50e1cc1f1604bb4fa779b34279efd50c
-rw-r--r--ansible/prune-images.yml9
-rw-r--r--ansible/roles/prune-images/defaults/main.yml2
-rw-r--r--ansible/roles/prune-images/tasks/main.yml4
-rw-r--r--ansible/roles/prune-images/tasks/prune_images.yml8
-rw-r--r--ansible/roles/prune-images/tasks/validate_docker_execute.yml3
-rw-r--r--doc/source/user/operating-kolla.rst3
-rw-r--r--releasenotes/notes/docker-image-pruning-fffcffa7e99c6e63.yaml7
-rwxr-xr-xtools/kolla-ansible14
8 files changed, 50 insertions, 0 deletions
diff --git a/ansible/prune-images.yml b/ansible/prune-images.yml
new file mode 100644
index 000000000..2b6a3adae
--- /dev/null
+++ b/ansible/prune-images.yml
@@ -0,0 +1,9 @@
+---
+- import_playbook: gather-facts.yml
+
+- name: Apply role prune-images
+ hosts: baremetal
+ serial: '{{ kolla_serial|default("0") }}'
+ gather_facts: false
+ roles:
+ - prune-images
diff --git a/ansible/roles/prune-images/defaults/main.yml b/ansible/roles/prune-images/defaults/main.yml
new file mode 100644
index 000000000..1cfdd158f
--- /dev/null
+++ b/ansible/roles/prune-images/defaults/main.yml
@@ -0,0 +1,2 @@
+---
+docker_image_prune_timeout: 300
diff --git a/ansible/roles/prune-images/tasks/main.yml b/ansible/roles/prune-images/tasks/main.yml
new file mode 100644
index 000000000..e6ba54591
--- /dev/null
+++ b/ansible/roles/prune-images/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+- include_tasks: validate_docker_execute.yml
+
+- include_tasks: prune_images.yml
diff --git a/ansible/roles/prune-images/tasks/prune_images.yml b/ansible/roles/prune-images/tasks/prune_images.yml
new file mode 100644
index 000000000..154e5e5f0
--- /dev/null
+++ b/ansible/roles/prune-images/tasks/prune_images.yml
@@ -0,0 +1,8 @@
+---
+- name: Pruning Kolla images
+ become: true
+ docker_prune:
+ images: yes
+ images_filters:
+ label: kolla_version
+ timeout: "{{ docker_image_prune_timeout }}"
diff --git a/ansible/roles/prune-images/tasks/validate_docker_execute.yml b/ansible/roles/prune-images/tasks/validate_docker_execute.yml
new file mode 100644
index 000000000..0e85832c6
--- /dev/null
+++ b/ansible/roles/prune-images/tasks/validate_docker_execute.yml
@@ -0,0 +1,3 @@
+---
+- name: Ensure the docker service is running
+ script: ../tools/validate-docker-execute.sh
diff --git a/doc/source/user/operating-kolla.rst b/doc/source/user/operating-kolla.rst
index 77cafd18e..18f946590 100644
--- a/doc/source/user/operating-kolla.rst
+++ b/doc/source/user/operating-kolla.rst
@@ -191,6 +191,9 @@ tests.
``kolla-ansible -i INVENTORY deploy-containers`` is used to check and if
necessary update containers, without generating configuration.
+``kolla-ansible -i INVENTORY prune-images`` is used to prune orphaned Docker
+images on hosts.
+
.. note::
In order to do smoke tests, requires ``kolla_enable_sanity_checks=yes``.
diff --git a/releasenotes/notes/docker-image-pruning-fffcffa7e99c6e63.yaml b/releasenotes/notes/docker-image-pruning-fffcffa7e99c6e63.yaml
new file mode 100644
index 000000000..b2a576a1a
--- /dev/null
+++ b/releasenotes/notes/docker-image-pruning-fffcffa7e99c6e63.yaml
@@ -0,0 +1,7 @@
+---
+features:
+ - |
+ Adds command ``prune-images`` for Docker image pruning on hosts. See
+ `blueprint
+ <https://blueprints.launchpad.net/kolla-ansible/+spec/docker-image-pruning>`__
+ for details.
diff --git a/tools/kolla-ansible b/tools/kolla-ansible
index 733c69c89..7f4022a79 100755
--- a/tools/kolla-ansible
+++ b/tools/kolla-ansible
@@ -88,6 +88,7 @@ Commands:
upgrade Upgrades existing OpenStack Environment
upgrade-bifrost Upgrades an existing bifrost container
genconfig Generate configuration files for enabled OpenStack services
+ prune-images Prune orphaned Kolla images
EOF
}
@@ -126,6 +127,7 @@ certificates
upgrade
upgrade-bifrost
genconfig
+prune-images
EOF
}
@@ -391,6 +393,18 @@ EOF
ACTION="Generate configuration files for enabled OpenStack services"
EXTRA_OPTS="$EXTRA_OPTS -e kolla_action=config"
;;
+(prune-images)
+ ACTION="Prune orphaned Kolla images"
+ PLAYBOOK="${BASEDIR}/ansible/prune-images.yml"
+ if [[ "${DANGER_CONFIRM}" != "--yes-i-really-really-mean-it" ]]; then
+ cat << EOF
+WARNING:
+ This will PERMANENTLY DELETE all orphaned kolla images. To confirm, please add the following option:
+ --yes-i-really-really-mean-it
+EOF
+ exit 1
+ fi
+ ;;
(bash-completion)
bash_completion
exit 0