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
This commit is contained in:
Eduardo Gonzalez 2016-11-13 16:15:08 +00:00
parent 57ee8b3751
commit da83802b1b
2 changed files with 12 additions and 7 deletions

View File

@ -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

View File

@ -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