Tolerate network errors in pingtest retry logic

We use ping -w <deadline> -c <count>. This will ping every second until
<count> replies are received, or <deadline> is reached, or a network error occurs.

With the current retry logic a network error will result in a short tight loop
instead of waiting for the network to come up.

This change reduces the deadline to 10s, but sleeps 60s between retries.

Change-Id: Ib00cff6f843c04a00737b40e3ef3d1560d6e6d2d
Related-bug: #1680167
Oliver Walsh 2017-06-30 11:51:06 +01:00
parent 876bafb8e9
commit 6a64a4a9d2
1 changed files with 2 additions and 1 deletions

View File

@ -10,12 +10,13 @@ function ping_retry() {
until [ $COUNT -ge $TIMES ]; do
if $PING_CMD -w 300 -c 1 $IP_ADDR &> /dev/null; then
if $PING_CMD -w 10 -c 1 $IP_ADDR &> /dev/null; then
echo "Ping to $IP_ADDR succeeded."
return 0
echo "Ping to $IP_ADDR failed. Retrying..."
COUNT=$(($COUNT + 1))
sleep 60
return 1