From 302565ad0b987e0b9cb53b3007ddfd60235f5ffd Mon Sep 17 00:00:00 2001 From: WenyXu Date: Wed, 28 Oct 2026 14:54:24 +0000 Subject: [PATCH] fix(ci): retry helper image publication on registry timeouts Signed-off-by: WenyXu --- .../publish-query-regression-helpers.sh | 14 +++++++++- tests/perf/test_query_regression_helpers.py | 26 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/scripts/publish-query-regression-helpers.sh b/.github/scripts/publish-query-regression-helpers.sh index 1a02be233d9..83d9d15e0fa 100644 --- a/.github/scripts/publish-query-regression-helpers.sh +++ b/.github/scripts/publish-query-regression-helpers.sh @@ -15,7 +15,19 @@ for binary in query_perf_fixture query_regression_runner; do done docker build --build-arg "SOURCE_REVISION=$revision" \ --file docker/query-regression-helpers/Dockerfile --tag "$tag" "$staging" -docker push "$tag" +# ACR token exchange can time out even after docker login succeeds. Retry +# publication without rebuilding the binaries or changing the image tag. +for attempt in 1 2 3; do + if timeout 600 docker push "$tag"; then + break + fi + if [[ "$attempt" == 3 ]]; then + echo "Helper image push failed after $attempt attempts." >&2 + exit 1 + fi + echo "Helper image push failed (attempt $attempt/3); retrying in 15 seconds." >&2 + sleep 15 +done image="$(docker image inspect "$tag" --format '{{index .RepoDigests 0}}')" [[ "$image" == "$repository@sha256:"* ]] # Verify the published artifact through the same extraction path as consumers. diff --git a/tests/perf/test_query_regression_helpers.py b/tests/perf/test_query_regression_helpers.py index ef4a8637565..9810c9f4366 100644 --- a/tests/perf/test_query_regression_helpers.py +++ b/tests/perf/test_query_regression_helpers.py @@ -83,6 +83,32 @@ class HelpersTest(unittest.TestCase): helpers.extract(IMAGE, Path(tmp)) self.assertEqual(run.call_count, 2) + def test_publish_retries_same_tag_and_stops_after_three_failures(self): + import os + script = (ROOT / ".github/scripts/publish-query-regression-helpers.sh").read_text() + retry = script.split("for attempt in 1 2 3; do", 1)[1].split('image="', 1)[0] + retry = "set -euo pipefail\ntag=registry/helpers:revision\nfor attempt in 1 2 3; do" + retry + for failures in (0, 1, 3): + with self.subTest(failures=failures), tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) + docker = root / "docker" + docker.write_text("""#!/bin/sh +printf '%s\\n' "$*" >> "$PUSH_LOG" +attempt=$(wc -l < "$PUSH_LOG") +[ "$attempt" -gt "$FAILURES" ] +""") + docker.chmod(0o755) + sleep = root / "sleep" + sleep.write_text("#!/bin/sh\nexit 0\n") + sleep.chmod(0o755) + log = root / "pushes" + env = dict(os.environ, PATH=tmp + os.pathsep + os.environ["PATH"], + PUSH_LOG=str(log), FAILURES=str(failures)) + result = subprocess.run(["bash", "-c", retry], env=env, capture_output=True) + self.assertEqual(result.returncode, 1 if failures == 3 else 0) + self.assertEqual(log.read_text().splitlines(), + ["push registry/helpers:revision"] * min(failures + 1, 3)) + def test_candidate_build_matrix(self): # Execute the actual workflow shell with recorder commands. Changing # only image inputs must preserve source defaults and skip opted-in builds.