diff --git a/.github/scripts/merge-manifests.sh b/.github/scripts/merge-manifests.sh index 03ca2531..7884235f 100755 --- a/.github/scripts/merge-manifests.sh +++ b/.github/scripts/merge-manifests.sh @@ -20,7 +20,8 @@ failed=0 for lt in "${!LOGICAL[@]}"; do if [ -n "${HAS_AMD64[$lt]:-}" ] && [ -n "${HAS_ARM64[$lt]:-}" ]; then echo "Creating multi-arch manifest: $lt" - if ! docker buildx imagetools create --tag "$lt" "${lt}-amd64" "${lt}-arm64"; then + # Retried (with-retry.sh): a brief registry 5xx must not leave this tag stale or missing. + if ! "$HERE/with-retry.sh" docker buildx imagetools create --tag "$lt" "${lt}-amd64" "${lt}-arm64"; then echo "::error::Failed to create multi-arch manifest for $lt" failed=1 continue diff --git a/.github/scripts/tests/run.sh b/.github/scripts/tests/run.sh index f5cd2605..8d771066 100755 --- a/.github/scripts/tests/run.sh +++ b/.github/scripts/tests/run.sh @@ -263,11 +263,21 @@ assert_contains "$(cat "$logM")" "buildx imagetools create --tag pimcore/pimcore assert_not_contains "$outM" "Creating multi-arch manifest: pimcore/pimcore:php8.5-onlyone" "M single-arch tag skipped (not created)" assert_contains "$outM" "Skipping pimcore/pimcore:php8.5-onlyone" "M single-arch tag reported as skipped" -# imagetools create failure -> non-zero exit +# imagetools create keeps failing -> non-zero exit once the retries are used up +# (RETRY_DELAY=0: no sleeps between attempts) wMf="$(mktemp -d)"; tmpdirs+=("$wMf") printf '%s\n' "pimcore/pimcore:x-amd64" "pimcore/pimcore:x-arm64" > "$wMf/agg.txt" -AGG_FILE="$wMf/agg.txt" STUB_IMAGETOOLS=fail STUB_LOG="$wMf/stub.log" "${ROOT}/.github/scripts/merge-manifests.sh"; rcMf=$? +AGG_FILE="$wMf/agg.txt" STUB_IMAGETOOLS=fail RETRY_DELAY=0 STUB_LOG="$wMf/stub.log" "${ROOT}/.github/scripts/merge-manifests.sh"; rcMf=$? [ "$rcMf" != 0 ] && echo " ok: Mf exit non-zero on create failure" || { echo " FAIL: Mf should fail"; fail=1; } +assert_eq "$(grep -c 'imagetools create' "$wMf/stub.log")" "3" "Mf create attempted RETRY_MAX (default 3) times before giving up" + +# REGRESSION: a transient imagetools create failure (brief registry 5xx) is retried, +# so the logical tag is still published instead of being left stale or missing. +wMr="$(mktemp -d)"; tmpdirs+=("$wMr") +printf '%s\n' "pimcore/pimcore:x-amd64" "pimcore/pimcore:x-arm64" > "$wMr/agg.txt" +AGG_FILE="$wMr/agg.txt" STUB_IMAGETOOLS=flaky STUB_FLAKY_MARK="$wMr/failed-once" RETRY_DELAY=0 STUB_LOG="$wMr/stub.log" "${ROOT}/.github/scripts/merge-manifests.sh"; rcMr=$? +assert_eq "$rcMr" "0" "Mr transient create failure is retried -> exit 0" +assert_eq "$(grep -c 'imagetools create' "$wMr/stub.log")" "2" "Mr create attempted twice (1 failure + 1 retry)" # Task 2: tagsbom format -> attach both per-arch SBOMs to the logical tag wS="$(mktemp -d)"; tmpdirs+=("$wS"); mkdir -p "$wS/sboms" diff --git a/.github/scripts/tests/stubs/docker b/.github/scripts/tests/stubs/docker index 68db377e..f7495f5c 100755 --- a/.github/scripts/tests/stubs/docker +++ b/.github/scripts/tests/stubs/docker @@ -7,9 +7,15 @@ if [ "$1 $2" = "image inspect" ]; then if printf '%s ' "$@" | grep -q -- '--format'; then echo "sha256:deadbeefcafe0000"; fi exit 0 fi -# imagetools create failure knob: STUB_IMAGETOOLS=fail +# imagetools create failure knobs: STUB_IMAGETOOLS=fail (every call), or +# STUB_IMAGETOOLS=flaky (first call only, like a brief registry 5xx; the marker +# file STUB_FLAKY_MARK records that the one failure already happened). if [ "${1:-}" = "buildx" ] && [ "${2:-}" = "imagetools" ] && [ "${3:-}" = "create" ]; then [ "${STUB_IMAGETOOLS:-ok}" = "fail" ] && { echo "stub docker: imagetools create failed" >&2; exit 1; } + if [ "${STUB_IMAGETOOLS:-ok}" = "flaky" ] && [ ! -e "${STUB_FLAKY_MARK:?}" ]; then + : > "$STUB_FLAKY_MARK" + echo "stub docker: imagetools create failed (transient)" >&2; exit 1 + fi exit 0 fi exit 0