ci(core): Retry sending data over TCP in case of error

The first attempt occasionally fails, probably due to a race with the
listener's startup.

Additionally, perform minor adjustments to the output written to stderr
to ensure it is properly flushed in the CI environment.
This commit is contained in:
Antoine Cotten
2021-10-28 16:41:49 +02:00
parent c3cc7ae15c
commit 9fde1ac351
4 changed files with 56 additions and 12 deletions

View File

@@ -23,6 +23,8 @@ function container_id {
local cid
local -i was_retried=0
# retry for max 60s (30*2s)
for _ in $(seq 1 30); do
cid="$(docker container ls -aq -f label="$label")"
@@ -30,9 +32,14 @@ function container_id {
break
fi
was_retried=1
echo -n '.' >&2
sleep 2
done
if ((was_retried)); then
# flush stderr, important in non-interactive environments (CI)
echo >&2
fi
if [ -z "${cid:-}" ]; then
err "Timed out waiting for creation of container with label ${label}"
@@ -91,6 +98,8 @@ function poll_ready {
local -i result=1
local output
local -i was_retried=0
# retry for max 300s (60*5s)
for _ in $(seq 1 60); do
if [[ $(docker container inspect "$cid" --format '{{ .State.Status}}') == 'exited' ]]; then
@@ -104,9 +113,14 @@ function poll_ready {
break
fi
was_retried=1
echo -n 'x' >&2
sleep 5
done
if ((was_retried)); then
# flush stderr, important in non-interactive environments (CI)
echo >&2
fi
echo -e "\n${output::-3}"