Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit b5408dd

Browse files
authored
Retrying to get CONTAINER_IP when using Zalenium (#205)
* Waiting for CONTAINER_IP a bit when using Zalenium zalando/zalenium#396 * Adding message to simplify debugging
1 parent 60cb7f8 commit b5408dd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

bin/entry.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,20 @@ export DOCKER_HOST_IP=$(netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}')
143143
# export CONTAINER_IP=$(ip addr show dev ${ETHERNET_DEVICE_NAME} | grep "inet " | awk '{print $2}' | cut -d '/' -f 1)
144144
# 2017-09 Found a more portable, even works in alpine:
145145
export CONTAINER_IP=`getent hosts ${HOSTNAME} | awk '{ print $1 }'`
146+
# Trying again to retrieve the container IP when using Zalenium
147+
if [ "${ZALENIUM}" == "true" ] && [ "${CONTAINER_IP}" == "" ]; then
148+
# Sometimes the networking is not fast and the container IP is not there, we retry a few times for one minute to get it.
149+
echo "Retrying to get CONTAINER_IP..." 1>&2
150+
WAIT_UNTIL=$((SECONDS + 60))
151+
while [ $SECONDS -lt ${WAIT_UNTIL} ]; do
152+
export CONTAINER_IP=`getent hosts ${HOSTNAME} | awk '{ print $1 }'`
153+
if [ "${CONTAINER_IP}" != "" ]; then
154+
break
155+
fi
156+
echo -n '.'
157+
sleep 2
158+
done
159+
fi
146160

147161
# if [ "${DOCKER_HOST_IP}" == "" ] || [[ ${DOCKER_HOST_IP} == 127* ]]; then
148162
# # TODO: Try with an alternative method

0 commit comments

Comments
 (0)