Fix cleanup-containers script

kolla-ansible destroy properly fails if qemu processes
are running in compute nodes.
Manually executing ./cleanup-container won't because
$COMPUTE variable is not defined anywhere.

Change-Id: I304c59ec682a93035e631490bbba7b355b1fcae2
Closes-Bug: #1656864
This commit is contained in:
Eduardo Gonzalez 2017-01-16 15:46:38 +00:00
parent e6b235e1c7
commit 0581d3b319
2 changed files with 5 additions and 11 deletions

View File

@ -1,10 +1,3 @@
---
- name: Destroying all Kolla containers and volumes on compute node
environment:
COMPUTE: true
- name: Destroying all Kolla containers and volumes
command: /tmp/kolla-cleanup/tools/cleanup-containers
when: inventory_hostname in groups['compute']
- name: Destroying all Kolla containers and volumes on non compute node
command: /tmp/kolla-cleanup/tools/cleanup-containers
when: inventory_hostname not in groups['compute']

View File

@ -1,6 +1,9 @@
#!/bin/bash
containers_running=$(docker ps --filter "label=kolla_version" --format "{{.Names}}")
QEMU_PIDS=$(pgrep -l qemu | awk '!/qemu-ga/ {print $1}')
if [[ $COMPUTE ]] && [[ $QEMU_PIDS ]] && [[ $(ps --no-headers wwwup $QEMU_PIDS | grep --invert-match '\-xen\-domid 0') ]]; then
if [[ "${containers_running}" =~ "nova_libvirt" ]] && [[ $QEMU_PIDS ]] && [[ $(ps --no-headers wwwup $QEMU_PIDS | grep --invert-match '\-xen\-domid 0') ]]; then
echo "Some qemu processes were detected."
echo "Docker will not be able to stop the nova_libvirt container with those running."
echo "Please clean them up before rerunning this script."
@ -18,8 +21,6 @@ else
egrep -v '(^\s*$)' | sort | uniq)
fi
containers_running=$(docker ps --filter "label=kolla_version" --format "{{.Names}}")
if [[ "${containers_to_kill}" =~ "openvswitch_vswitchd" ]] && [[ "${containers_running}" =~ "neutron_openvswitch_agent" ]]; then
echo "Removing ovs bridge..."
(docker exec -u root neutron_openvswitch_agent neutron-ovs-cleanup \