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
This commit is contained in:
parent
bcc09ed2b4
commit
b7728ea890
9
ansible/prune-images.yml
Normal file
9
ansible/prune-images.yml
Normal file
@ -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
|
2
ansible/roles/prune-images/defaults/main.yml
Normal file
2
ansible/roles/prune-images/defaults/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
docker_image_prune_timeout: 300
|
4
ansible/roles/prune-images/tasks/main.yml
Normal file
4
ansible/roles/prune-images/tasks/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
- include_tasks: validate_docker_execute.yml
|
||||||
|
|
||||||
|
- include_tasks: prune_images.yml
|
8
ansible/roles/prune-images/tasks/prune_images.yml
Normal file
8
ansible/roles/prune-images/tasks/prune_images.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: Pruning Kolla images
|
||||||
|
become: true
|
||||||
|
docker_prune:
|
||||||
|
images: yes
|
||||||
|
images_filters:
|
||||||
|
label: kolla_version
|
||||||
|
timeout: "{{ docker_image_prune_timeout }}"
|
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
- name: Ensure the docker service is running
|
||||||
|
script: ../tools/validate-docker-execute.sh
|
@ -191,6 +191,9 @@ tests.
|
|||||||
``kolla-ansible -i INVENTORY deploy-containers`` is used to check and if
|
``kolla-ansible -i INVENTORY deploy-containers`` is used to check and if
|
||||||
necessary update containers, without generating configuration.
|
necessary update containers, without generating configuration.
|
||||||
|
|
||||||
|
``kolla-ansible -i INVENTORY prune-images`` is used to prune orphaned Docker
|
||||||
|
images on hosts.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
In order to do smoke tests, requires ``kolla_enable_sanity_checks=yes``.
|
In order to do smoke tests, requires ``kolla_enable_sanity_checks=yes``.
|
||||||
|
@ -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.
|
@ -88,6 +88,7 @@ Commands:
|
|||||||
upgrade Upgrades existing OpenStack Environment
|
upgrade Upgrades existing OpenStack Environment
|
||||||
upgrade-bifrost Upgrades an existing bifrost container
|
upgrade-bifrost Upgrades an existing bifrost container
|
||||||
genconfig Generate configuration files for enabled OpenStack services
|
genconfig Generate configuration files for enabled OpenStack services
|
||||||
|
prune-images Prune orphaned Kolla images
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +127,7 @@ certificates
|
|||||||
upgrade
|
upgrade
|
||||||
upgrade-bifrost
|
upgrade-bifrost
|
||||||
genconfig
|
genconfig
|
||||||
|
prune-images
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,6 +393,18 @@ EOF
|
|||||||
ACTION="Generate configuration files for enabled OpenStack services"
|
ACTION="Generate configuration files for enabled OpenStack services"
|
||||||
EXTRA_OPTS="$EXTRA_OPTS -e kolla_action=config"
|
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)
|
||||||
bash_completion
|
bash_completion
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user