labs: wait for namespaces and interfaces

When setting up neutron router and DHCP, the time until namespaces and
interfaces are ready varies a lot (from less than a second to five
seconds and more), even on the same host system. If it takes longer, we
proceed too early which leaves the cluster misconfigured. In that case,
nova instances fail to get a DHCP address.

This patch makes sure the script waits until the interfaces are ready.

Change-Id: I346a098062d984956cf496e89f9ada2a38df0569
This commit is contained in:
Roger Luethi 2014-09-19 14:25:11 +02:00
parent 2dd44182f3
commit 6045d3c2fd

View File

@ -135,7 +135,56 @@ iniset_sudo $conf DEFAULT verbose True
echo "Restarting the network service."
sudo service neutron-plugin-openvswitch-agent restart
sudo service neutron-l3-agent restart
echo -n "Getting router namespace."
nsrouter=$(ip netns|grep qrouter)
while [ : ]; do
nsrouter=$(ip netns|grep qrouter)
if [ -n "$nsrouter" ]; then
echo
echo "Router namespace: $nsrouter"
break
fi
echo -n "."
sleep 1
done
sudo service neutron-dhcp-agent restart
echo -n "Getting DHCP namespace."
while [ : ]; do
nsdhcp=$(ip netns|grep qdhcp)
if [ -n "$nsdhcp" ]; then
echo
echo "DHCP namespace: $nsdhcp"
break
fi
echo -n "."
sleep 1
done
echo -n "Waiting for interfaces qr-*, qg-* in router namespace."
while [ : ]; do
ifaces=$(sudo ip netns exec "$nsrouter" ip addr)
if [[ $ifaces == *:\ qr-* && $ifaces == *:\ qg-* ]]; then
echo
break
fi
echo -n "."
sleep 1
done
echo -n "Waiting for interface tap* in DHCP namespace."
while [ : ]; do
ifaces=$(sudo ip netns exec "$nsdhcp" ip addr)
if [[ $ifaces == *:\ tap* ]]; then
echo
break
fi
echo -n "."
sleep 1
done
sudo service neutron-metadata-agent restart
echo "Restarting the OVS agent."