Merge "Add a 60 seconds timeout to ping_metadata_ip()"

This commit is contained in:
Zuul 2018-05-26 02:04:43 +00:00 committed by Gerrit Code Review
commit 5d9038c568
1 changed files with 3 additions and 1 deletions

View File

@ -27,6 +27,7 @@ function is_local_ip() {
function ping_metadata_ip() {
local METADATA_IP=$(get_metadata_ip)
local METADATA_IP_PING_TIMEOUT=60
if [ -n "$METADATA_IP" ] && ! is_local_ip $METADATA_IP; then
@ -35,7 +36,8 @@ function ping_metadata_ip() {
local COUNT=0
until ping -c 1 $METADATA_IP &> /dev/null; do
COUNT=$(( $COUNT + 1 ))
if [ $COUNT -eq 10 ]; then
sleep 1
if [ $COUNT -eq $METADATA_IP_PING_TIMEOUT ]; then
echo "FAILURE"
echo "$METADATA_IP is not pingable." >&2
exit 1