Add a 60 seconds timeout to ping_metadata_ip()

Closes-Bug: #1735849

Change-Id: I1004c2d764339c30653e2f4a3c7aee1343a20b4e
This commit is contained in:
David Vallee Delisle 2018-01-20 12:15:11 -05:00 committed by David Vallee Delisle
parent e86b30a73f
commit d0de91cd78
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