From: David Galloway Date: Tue, 20 Mar 2018 15:22:53 +0000 (-0400) Subject: cobbler: Change method used to ping Cobbler host in rc.local X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=783b2b4ab51ca3bdb9b88a3a63c3cdc88287fa44;p=ceph-cm-ansible.git cobbler: Change method used to ping Cobbler host in rc.local I've observed a *very* occasional race condition where dhclient completes but the host can't ping Cobbler. Instead of timing out waiting for one ping packet to return, we'll try pinging X number of times (based on $attempts number) and then give up. I'll paste an example of the race condition observed in the PR notes. Signed-off-by: David Galloway --- diff --git a/roles/cobbler/templates/snippets/cephlab_rc_local b/roles/cobbler/templates/snippets/cephlab_rc_local index b87bcd2..7149662 100644 --- a/roles/cobbler/templates/snippets/cephlab_rc_local +++ b/roles/cobbler/templates/snippets/cephlab_rc_local @@ -37,9 +37,15 @@ if [ ! -f /.cephlab_net_configured ]; then # Don't bail if NIC fails to come up set +e ifup $nic + attempts=0 + # Try for 5 seconds to ping our Cobbler host #end raw - if ! timeout 5s ping -I $nic -nq -c1 $http_server 2>&1 >/dev/null; then + while ! ping -I $nic -nq -c1 $http_server && [ $attempts -lt 5 ]; do #raw + sleep 1 + attempts=$[$attempts+1] + done + if [ $attempts == 5 ]; then # If we can't ping our Cobbler host, remove the DHCP config for this NIC. # It must either be on a non-routable network or has no reachable DHCP server. ifdown $nic