From da83802b1b01eb442a551c19eddef063751d008b Mon Sep 17 00:00:00 2001 From: Eduardo Gonzalez Date: Sun, 13 Nov 2016 16:15:08 +0000 Subject: [PATCH] Fix ovs-cleanup issue at cleanup scripts Move ovs-cleanup step to cleanup-containers, otherwise bridges will not be removed because neutron_openvswitch_agent container does not exists after running cleanup-containers. Add logic to cleanup ovs bridges only when openvswitch_db is removed and openvswitch-agent is running, so when removing other container from a parameter at script invocation ovs-cleanup will not be executed. Change-Id: Ie5fea40426df0e9e465fc173aba185f61098f676 Closes-Bug: #1640178 --- tools/cleanup-containers | 14 ++++++++++++-- tools/cleanup-host | 5 ----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/cleanup-containers b/tools/cleanup-containers index a07c1d4d13..099e5b234e 100755 --- a/tools/cleanup-containers +++ b/tools/cleanup-containers @@ -8,8 +8,9 @@ if [[ $COMPUTE ]] && [[ $QEMU_PIDS ]] && [[ $(ps --no-headers wwwup $QEMU_PIDS | fi if [ -n "$1" ]; then - containers_to_kill=($(docker ps | grep -E "$1" | awk '{print $1}')) - volumes_to_remove=($(docker volume ls | grep -E "$1" | awk '{print $1}')) + containers_to_kill=($(docker ps --filter "label=kolla_version" --format "{{.Names}}" -a | grep -E "$1" | awk '{print $1}')) + volumes_to_remove=($(docker inspect -f '{{range .Mounts}} {{printf "%s\n" .Name }}{{end}}' $1 | \ + egrep -v '(^\s*$)' | sort | uniq)) else containers_to_kill=$(docker ps --filter "label=kolla_version" --format "{{.Names}}" -a) @@ -17,6 +18,15 @@ 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 \ + --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini \ + --ovs_all_ports) > /dev/null +fi + echo "Stopping containers..." (docker stop -t 2 ${containers_to_kill} 2>&1) > /dev/null diff --git a/tools/cleanup-host b/tools/cleanup-host index 59d463b226..c319ce0b83 100755 --- a/tools/cleanup-host +++ b/tools/cleanup-host @@ -27,11 +27,6 @@ ip -o link show | awk -F': ' '/vxlan/{print $2}' | while read -r ifname ; do ip link delete $ifname type vxlan done -echo "Removing ovs bridge..." -(docker exec -u root neutron_openvswitch_agent neutron-ovs-cleanup \ - --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini \ - --ovs_all_ports) > /dev/null - # Keepalived leaves VIP on the host in case of accidental removal. # This snippet removes VIPs. if [[ "$enable_haproxy" == "yes" ]]; then