Skip to content

Commit

Permalink
Check also hostname when waiting for external address (knative#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgencur authored and knative-prow-robot committed Jan 23, 2019
1 parent 156848d commit f0778cc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,26 @@ function wait_until_pods_running() {
return 1
}

# Waits until the given service has an external IP address.
# Waits until the given service has an external address (IP/hostname).
# Parameters: $1 - namespace.
# $2 - service name.
function wait_until_service_has_external_ip() {
echo -n "Waiting until service $2 in namespace $1 has an external IP"
echo -n "Waiting until service $2 in namespace $1 has an external address (IP/hostname)"
for i in {1..150}; do # timeout after 15 minutes
local ip=$(kubectl get svc -n $1 $2 -o jsonpath="{.status.loadBalancer.ingress[0].ip}")
if [[ -n "${ip}" ]]; then
echo -e "\nService $2.$1 has IP $ip"
return 0
fi
local hostname=$(kubectl get svc -n $1 $2 -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
if [[ -n "${hostname}" ]]; then
echo -e "\nService $2.$1 has hostname $hostname"
return 0
fi
echo -n "."
sleep 6
done
echo -e "\n\nERROR: timeout waiting for service $svc.$ns to have an external IP"
echo -e "\n\nERROR: timeout waiting for service $svc.$ns to have an external address"
kubectl get pods -n $1
return 1
}
Expand Down

0 comments on commit f0778cc

Please sign in to comment.