From 38f6271773a2682730f2a3aaa02dc9d5a676f703 Mon Sep 17 00:00:00 2001 From: NachoEchevarria Date: Mon, 13 Apr 2026 17:38:16 +0200 Subject: [PATCH] Docker run retry --- .azure-pipelines/steps/run-in-docker.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.azure-pipelines/steps/run-in-docker.yml b/.azure-pipelines/steps/run-in-docker.yml index 11b818ca7f51..3f7f5916e981 100644 --- a/.azure-pipelines/steps/run-in-docker.yml +++ b/.azure-pipelines/steps/run-in-docker.yml @@ -61,6 +61,30 @@ steps: echo "Using SDK version $sdkVersion" + # Retry wrapper for transient Docker daemon errors (e.g., D-Bus/cgroup flakes). + # Exit code 125 = Docker daemon error (container creation failure, not a test/build failure). + docker_run_with_retry() { + local max_retries=3 + local retry_delay=10 + local attempt=1 + while [ "$attempt" -le "$max_retries" ]; do + "$@" + local exit_code=$? + if [ "$exit_code" -eq 0 ]; then + return 0 + fi + echo "##[warning][docker-retry] docker run failed with exit code ${exit_code} on attempt ${attempt}/${max_retries}." + if [ "$exit_code" -eq 125 ] && [ "$attempt" -lt "$max_retries" ]; then + echo "##[warning][docker-retry] Exit code 125 indicates a Docker daemon error. Retrying in ${retry_delay}s..." + sleep "$retry_delay" + attempt=$((attempt + 1)) + continue + fi + return "$exit_code" + done + } + + docker_run_with_retry \ docker run --rm \ --cap-add=SYS_PTRACE \ --mount type=bind,source="$(System.DefaultWorkingDirectory)",target=/project \