From 56669b506dda09b1363bc1b7240e8e76269ff83e Mon Sep 17 00:00:00 2001 From: Roger Luethi Date: Sun, 19 Jul 2015 17:35:11 +0200 Subject: [PATCH] Wait for floating IP to turn up Since Juno, the floating IP often takes a long time to become pingable. Hopefully, this will be fixed, but for the time being we just ping the floating IP until we get a reply (or we reach a time limit and give up). This patch makes the test script wait longer for the floating IP. Change-Id: I8838aa7dc9b29274ea98401ce8d3ba3033a0dd0d --- labs/scripts/test/launch_instance.sh | 34 ++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/labs/scripts/test/launch_instance.sh b/labs/scripts/test/launch_instance.sh index 879d4fc5..c9d0e977 100755 --- a/labs/scripts/test/launch_instance.sh +++ b/labs/scripts/test/launch_instance.sh @@ -680,8 +680,38 @@ echo "Checking the status of your floating IP address." nova list echo -echo "Verifying network connectivity to instance VM." -ping -c1 "$floating_ip" +echo -n "Verifying network connectivity to instance VM (may take 2+ min)." +# Since Juno, the floating IP often takes a long time to become pingable. +# Hopefully, this will be fixed, but for the time being we just ping the +# floating IP until we get a reply (or we reach a time limit and give up). +function patient_ping { + local ip=$1 + local cnt=0 + + while [ : ]; do + echo -n . + sleep 1 + + # Ping the instance VM every ten seconds + if [[ $((cnt % 10)) -eq 0 ]]; then + if ping -c1 "$floating_ip" > /dev/null ; then + ping -c1 "$floating_ip" + echo "SUM ping instance VM after $cnt seconds." + break + fi + fi + + # Abort if it takes too long + if [[ $cnt -gt 600 ]]; then + echo "SUM ERROR no ping for instance VM in $cnt seconds. Aborting." + exit 1 + fi + + cnt=$((cnt + 1)) + done +} + +patient_ping "$floating_ip" echo echo "Accessing our instance using SSH from the controller node."