Skip to content

Commit

Permalink
Add wait for app to be routable function in library.sh (knative#128)
Browse files Browse the repository at this point in the history
* Add wait for app to be routable function in library

* Add function documentation

* Make log statements better

* Nuke stderr

* Assorted nits

* indentation, punctuation, linefeeds
* add log message about what the function is doing 
* use the same loop pattern as the other functions
  • Loading branch information
srinivashegde86 authored and knative-prow-robot committed Sep 18, 2018
1 parent 9914e68 commit d8b46ab
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scripts/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,24 @@ function wait_until_service_has_external_ip() {
return 1
}

# Waits for the endpoint to be routable.
# Parameters: $1 - External ingress IP address.
# $2 - cluster hostname.
function wait_until_routable() {
echo -n "Waiting until cluster $2 at $1 has a routable endpoint"
for i in {1..150}; do # timeout after 5 minutes
local val=$(curl -H "Host: $2" "http://$1" 2>/dev/null)
if [[ -n "$val" ]]; then
echo "\nEndpoint is now routable"
return 0
fi
echo -n "."
sleep 2
done
echo -e "\n\nERROR: Timed out waiting for endpoint to be routable"
return 1
}

# Returns the name of the pod of the given app.
# Parameters: $1 - app name.
# $2 - namespace (optional).
Expand Down

0 comments on commit d8b46ab

Please sign in to comment.