From 03c46ef75b514e8ae89a79c007ee9e186bf81d2f Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Sat, 20 Jan 2018 11:45:23 +0100 Subject: [PATCH 1/2] Waiting for CONTAINER_IP a bit when using Zalenium https://github.com/zalando/zalenium/issues/396 --- bin/entry.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/entry.sh b/bin/entry.sh index 62615558..b9730565 100755 --- a/bin/entry.sh +++ b/bin/entry.sh @@ -143,6 +143,19 @@ export DOCKER_HOST_IP=$(netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}') # export CONTAINER_IP=$(ip addr show dev ${ETHERNET_DEVICE_NAME} | grep "inet " | awk '{print $2}' | cut -d '/' -f 1) # 2017-09 Found a more portable, even works in alpine: export CONTAINER_IP=`getent hosts ${HOSTNAME} | awk '{ print $1 }'` +# Trying again to retrieve the container IP when using Zalenium +if [ "${ZALENIUM}" == "true" ] && [ "${CONTAINER_IP}" == "" ]; then + # Sometimes the networking is not fast and the container IP is not there, we retry a few times for one minute to get it. + WAIT_UNTIL=$((SECONDS + 60)) + while [ $SECONDS -lt ${WAIT_UNTIL} ]; do + export CONTAINER_IP=`getent hosts ${HOSTNAME} | awk '{ print $1 }'` + if [ "${CONTAINER_IP}" != "" ]; then + break + fi + echo -n '.' + sleep 2 + done +fi # if [ "${DOCKER_HOST_IP}" == "" ] || [[ ${DOCKER_HOST_IP} == 127* ]]; then # # TODO: Try with an alternative method From 160618b19c95f1d2df39f59cd2f8c9cef6e86f01 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Sat, 20 Jan 2018 16:45:30 +0100 Subject: [PATCH 2/2] Adding message to simplify debugging --- bin/entry.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/entry.sh b/bin/entry.sh index b9730565..8c262497 100755 --- a/bin/entry.sh +++ b/bin/entry.sh @@ -146,6 +146,7 @@ export CONTAINER_IP=`getent hosts ${HOSTNAME} | awk '{ print $1 }'` # Trying again to retrieve the container IP when using Zalenium if [ "${ZALENIUM}" == "true" ] && [ "${CONTAINER_IP}" == "" ]; then # Sometimes the networking is not fast and the container IP is not there, we retry a few times for one minute to get it. + echo "Retrying to get CONTAINER_IP..." 1>&2 WAIT_UNTIL=$((SECONDS + 60)) while [ $SECONDS -lt ${WAIT_UNTIL} ]; do export CONTAINER_IP=`getent hosts ${HOSTNAME} | awk '{ print $1 }'`