|
@ -695,19 +695,26 @@ wait_docker_ip() { |
|
|
} |
|
|
} |
|
|
export -f wait_docker_ip |
|
|
export -f wait_docker_ip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_BASH_IMAGE=${DEFAULT_BASH_IMAGE:-docker.0k.io/bash} |
|
|
wait_for_tcp_port() { |
|
|
wait_for_tcp_port() { |
|
|
local host_port=$1 timeout=30 start=$SECONDS |
|
|
|
|
|
|
|
|
local network=$1 host_port=$2 timeout=20 |
|
|
verb "Trying to connect to $host_port" |
|
|
verb "Trying to connect to $host_port" |
|
|
|
|
|
docker run --rm -i --network "$network" "$DEFAULT_BASH_IMAGE" <<EOF |
|
|
|
|
|
start=\$SECONDS |
|
|
while true; do |
|
|
while true; do |
|
|
timeout 1 bash -c "</dev/tcp/${host_port/://}" >/dev/null 2>&1 && break |
|
|
timeout 1 bash -c "</dev/tcp/${host_port/://}" >/dev/null 2>&1 && break |
|
|
sleep 0.2 |
|
|
sleep 0.2 |
|
|
if [ "$((SECONDS - start))" -gt "$timeout" ]; then |
|
|
|
|
|
|
|
|
if [ "\$((SECONDS - start))" -gt "$timeout" ]; then |
|
|
|
|
|
exit 1 |
|
|
|
|
|
fi |
|
|
|
|
|
done |
|
|
|
|
|
exit 0 |
|
|
|
|
|
EOF |
|
|
|
|
|
if [ "$?" == 1 ]; then |
|
|
err "${RED}timeout error${NORMAL}(${timeout}s):"\ |
|
|
err "${RED}timeout error${NORMAL}(${timeout}s):"\ |
|
|
"Could not connect to $host_port." |
|
|
"Could not connect to $host_port." |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
done |
|
|
|
|
|
return 0 |
|
|
return 0 |
|
|
} |
|
|
} |
|
|
export -f wait_for_tcp_port |
|
|
export -f wait_for_tcp_port |
|
@ -726,7 +733,7 @@ wait_for_docker_ip() { |
|
|
while read-0 port; do |
|
|
while read-0 port; do |
|
|
IFS="/" read port type <<<"$port" |
|
|
IFS="/" read port type <<<"$port" |
|
|
[ "$type" == "tcp" ] || continue |
|
|
[ "$type" == "tcp" ] || continue |
|
|
wait_for_tcp_port "$DOCKER_IP:${port}" || return 17 |
|
|
|
|
|
|
|
|
wait_for_tcp_port "$DOCKER_NETWORK" "$DOCKER_IP:${port}" || return 17 |
|
|
verb "Port $DOCKER_IP:${port} checked open." |
|
|
verb "Port $DOCKER_IP:${port} checked open." |
|
|
done < <(image_exposed_ports_0 "$container_id") |
|
|
done < <(image_exposed_ports_0 "$container_id") |
|
|
|
|
|
|
|
|