Fix for grenade slow discovery of e1000 network device

Ironic Inspector grenade job is using e1000 driver since
change: I4ec297281380896ffe9004c4de7117586ded7149

In some cases the e1000 devices has not registered yet,
and thus the dhcp init script does not find any interfaces
to bring up. This causes the grenade job to continue with
no network, and the job finally fail.

Add a check in the tinyipa dhcp init script, if no network
devices are present. Re-run udevadm --settle with a longer
timout and the re-discover devices in /proc/net/dev.

Let's hope another 5 seconds is enough. If not we now have
more logs to identify the issue.

Change-Id: I82beecc78afb4b23234d2d5eca4f46f84f20525e
This commit is contained in:
Harald Jensås
2018-10-11 19:13:54 +02:00
parent 855863fdc3
commit 4e107c7dfd
2 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#!/bin/sh
# The DHCP portion is now separated out, in order to not slow the boot down
# only to wait for slow network cards
. /etc/init.d/tc-functions
# This waits until all devices have registered
/sbin/udevadm settle --timeout=5
NETDEVICES="$(awk -F: '/eth.:|tr.:/{print $1}' /proc/net/dev 2>/dev/null)"
if [ -z $NETDEVICES ]; then
echo -e "\nWARNING: No network devices. Re-running udevadm --settle to wait for devices to register."
/sbin/udevadm settle --timeout=5
NETDEVICES="$(awk -F: '/eth.:|tr.:/{print $1}' /proc/net/dev 2>/dev/null)"
fi
echo -e "\n$0 - /proc/net/dev - network devices: $NETDEVICES discoverd."
for DEVICE in $NETDEVICES; do
ifconfig $DEVICE | grep -q "inet addr"
if [ "$?" != 0 ]; then
echo -e "\nNetwork device $DEVICE detected, DHCP broadcasting for IP."
trap 2 3 11
/sbin/udhcpc -b -i $DEVICE -x hostname:$(/bin/hostname) -p /var/run/udhcpc.$DEVICE.pid 2>&1 &
trap "" 2 3 11
sleep 1
fi
done

View File

@@ -147,6 +147,9 @@ sudo cp "$WORKDIR/build_files/bootlocal.sh" "$FINALDIR/opt/."
# Copy udhcpc.script to opt
sudo cp "$WORKDIR/udhcpc.script" "$FINALDIR/opt/"
# Replace etc/init.d/dhcp.sh
sudo cp "$WORKDIR/build_files/dhcp.sh" "$FINALDIR/etc/init.d/dhcp.sh"
# Disable ZSwap
sudo sed -i '/# Main/a NOZSWAP=1' "$FINALDIR/etc/init.d/tc-config"
# sudo cp $WORKDIR/build_files/tc-config $FINALDIR/etc/init.d/tc-config