Skip to content

Commit 4800c5e

Browse files
committed
Updated the elasticsearch-run CI script
1 parent 28bf0ed commit 4800c5e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

.ci/run-elasticsearch.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
# Export the TEST_SUITE variable, eg. 'oss' or 'xpack' defaults to 'oss'.
88
# Export the NUMBER_OF_NODES variable to start more than 1 node
99

10-
# Version 1.1.0
10+
# Version 1.2.0
1111
# - Initial version of the run-elasticsearch.sh script
1212
# - Deleting the volume should not dependent on the container still running
1313
# - Fixed `ES_JAVA_OPTS` config
1414
# - Moved to STACK_VERSION and TEST_VERSION
1515
# - Refactored into functions and imports
1616
# - Support NUMBER_OF_NODES
17+
# - Added 5 retries on docker pull for fixing transient network errors
1718

1819
script_path=$(dirname $(realpath -s $0))
1920
source $script_path/functions/imports.sh
@@ -67,6 +68,17 @@ if [[ "$TEST_SUITE" == "xpack" ]]; then
6768
cert_validation_flags="--insecure --cacert /usr/share/elasticsearch/config/certs/ca.crt --resolve ${es_node_name}:443:127.0.0.1"
6869
fi
6970

71+
# Pull the container, retry on failures up to 5 times with
72+
# short delays between each attempt. Fixes most transient network errors.
73+
docker_pull_attempts=0
74+
until [ "$docker_pull_attempts" -ge 5 ]
75+
do
76+
docker pull docker.elastic.co/elasticsearch/"$elasticsearch_container" && break
77+
docker_pull_attempts=$((docker_pull_attempts+1))
78+
echo "Failed to pull image, retrying in 10 seconds (retry $docker_pull_attempts/5)..."
79+
sleep 10
80+
done
81+
7082
NUMBER_OF_NODES=${NUMBER_OF_NODES-1}
7183
http_port=9200
7284
for (( i=0; i<$NUMBER_OF_NODES; i++, http_port++ )); do

0 commit comments

Comments
 (0)