From 0581d3b3196df5225a3d2aa18895cc8107bccc1d Mon Sep 17 00:00:00 2001 From: Eduardo Gonzalez Date: Mon, 16 Jan 2017 15:46:38 +0000 Subject: [PATCH] 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 --- ansible/roles/destroy/tasks/cleanup_containers.yml | 9 +-------- tools/cleanup-containers | 7 ++++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/ansible/roles/destroy/tasks/cleanup_containers.yml b/ansible/roles/destroy/tasks/cleanup_containers.yml index c6aee8ef5e..4ccdd9cdd8 100644 --- a/ansible/roles/destroy/tasks/cleanup_containers.yml +++ b/ansible/roles/destroy/tasks/cleanup_containers.yml @@ -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'] diff --git a/tools/cleanup-containers b/tools/cleanup-containers index 514befb5cd..612b34a620 100755 --- a/tools/cleanup-containers +++ b/tools/cleanup-containers @@ -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 \