Skip to content

Commit

Permalink
docker-test: fix condition for max tries
Browse files Browse the repository at this point in the history
Replace a recursive call with a loop.

Reported-by: Andrei Vagin <avagin@gmail.com>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
  • Loading branch information
rst0git committed Nov 29, 2023
1 parent d88dcef commit 2a4d534
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions scripts/ci/docker-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,24 @@ print_logs () {
}

declare -i max_restore_container_tries=3
current_iteration=

restore_container () {
CHECKPOINT_NAME=$1

docker start --checkpoint "$CHECKPOINT_NAME" cr 2>&1 | tee log || {
for i in $(seq $max_restore_container_tries); do
docker start --checkpoint "$CHECKPOINT_NAME" cr 2>&1 | tee log && break

# FIXME: There is a race condition in docker/containerd that causes
# docker to occasionally fail when starting a container from a
# checkpoint immediately after the checkpoint has been created.
# https://github.com/moby/moby/issues/42900
if [ "$current_iteration" -gt "$max_restore_container_tries" ]; then
print_logs
fi
grep -Eq '^Error response from daemon: failed to upload checkpoint to containerd: commit failed: content sha256:.*: already exists$' log && {
((current_iteration+=1))
echo "Retry container restore: $current_iteration"
echo "Retry container restore: $i/$max_restore_container_tries"
sleep 1;
restore_container "$CHECKPOINT_NAME"
} ||
print_logs
} && current_iteration=0

done
}

# Scenario: Create multiple containers and checkpoint and restore them once
Expand Down

0 comments on commit 2a4d534

Please sign in to comment.