Skip to content

Commit 7dbea68

Browse files
author
Marcus Sorensen
committed
Summary: Wait for VPC router nics to hotplug before assigning IPs
Detail: CLOUDSTACK-1452, CLOUDSTACK-1523 - When rebooting VPC routers, ip addr assignment was inconsistent, sometimes the assignment would be attempted while router was still setting up nic device. This adds a watch for the nic to show up before attempting to add an ip to a nic. Signed-off-by: Marcus Sorensen <marcus@betterservers.com> 1362521453 -0700
1 parent 9f180e4 commit 7dbea68

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

patches/systemvm/debian/config/opt/cloud/bin/vpc_guestnw.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ desetup_passwdsvcs() {
129129
}
130130

131131
create_guest_network() {
132+
# need to wait for eth device to appear before configuring it
133+
timer=0
134+
while ! `grep -q $dev /proc/net/dev` ; do
135+
logger -t cloud "$(basename $0):Waiting for interface $dev to appear, $timer seconds"
136+
sleep 1;
137+
if [ $timer -gt 15 ]; then
138+
logger -t cloud "$(basename $0):interface $dev never appeared"
139+
break
140+
fi
141+
timer=$[timer + 1]
142+
done
143+
132144
logger -t cloud " $(basename $0): Create network on interface $dev, gateway $gw, network $ip/$mask "
133145
# setup ip configuration
134146
sudo ip addr add dev $dev $ip/$mask brd +

patches/systemvm/debian/config/opt/cloud/bin/vpc_ipassoc.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ remove_routing() {
5656
}
5757

5858
add_an_ip () {
59+
# need to wait for eth device to appear before configuring it
60+
timer=0
61+
while ! `grep -q $ethDev /proc/net/dev` ; do
62+
logger -t cloud "$(basename $0):Waiting for interface $ethDev to appear, $timer seconds"
63+
sleep 1;
64+
if [ $timer -gt 15 ]; then
65+
logger -t cloud "$(basename $0):interface $ethDev never appeared"
66+
break
67+
fi
68+
timer=$[timer + 1]
69+
done
70+
5971
logger -t cloud "$(basename $0):Adding ip $pubIp on interface $ethDev"
6072
sudo ip link show $ethDev | grep "state DOWN" > /dev/null
6173
local old_state=$?

0 commit comments

Comments
 (0)