ci: arm64 policy - serialise legs, one retry, never drop an existing arm64, ELF check before publish
- max-parallel: 2 on the cac / cac-fpm matrices (8 concurrent QEMU legs failed on 2026-11-19) - ONE retry of a failed arm64 leg (90 s pause) in cac, cac-fpm, shared-httpd - assemble-multiarch-index.sh: --guard-existing-arm64 (fail instead of replacing a multi-arch tag by amd64-only; dispatch input allow_amd64_only overrides) and --verify-bin (ELF machine type of amd64 and arm64 before any tag is written) - tests: assemble-guard.test.sh, wiring tests; docs/arm64-publish-policy.md Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
1 parent
655c88f10b
commit
e1ea28e6a8
5 files changed
+274
-11
No files matched your search
@@ -8,7 +8,8 @@
|
||||
# --amd64 sha256:<digest> \
|
||||
# --arm64 sha256:<digest> --arm64-outcome success|failure|cancelled|skipped \
|
||||
# --repo <registry/path> [--repo <other registry/path> ...] \
|
||||
# --tag <tag> [--tag <tag> ...] [--builder <buildx builder>]
|
||||
# --tag <tag> [--tag <tag> ...] [--builder <buildx builder>] \
|
||||
# [--verify-bin PATH ...] [--guard-existing-arm64]
|
||||
#
|
||||
# Rules (all enforced here so the workflow stays thin and these are testable):
|
||||
# * amd64 is mandatory. A missing/malformed amd64 digest, or an amd64 digest
|
||||
@@ -19,16 +20,25 @@
|
||||
# published amd64-only (warning, exit 0). The arm64 digest must come from
|
||||
# THIS run's step output - the workflow never reads it from a registry tag,
|
||||
# so a previous build's arm64 can never be re-attached to a newer amd64.
|
||||
# * --verify-bin (repeatable): before anything is published, the amd64 entry must hold x86-64
|
||||
# and (if it would be attached) the arm64 entry AArch64 binaries at those paths
|
||||
# (scripts/verify-image-arch.py, nothing is executed). Wrong/unverifiable amd64 = exit 1,
|
||||
# nothing published. Wrong/unverifiable arm64 = treated as a failed arm64 leg.
|
||||
# * --guard-existing-arm64: if the result would be amd64-only and a CURRENT tag already has a
|
||||
# linux/arm64 entry, exit 1 and publish nothing (never silently drop arm64), unless
|
||||
# env ALLOW_AMD64_ONLY=true. An unreadable tag fails closed; a missing tag is fine.
|
||||
# * every --tag is created in every --repo from <repo>@<digest> sources in
|
||||
# that same repo (both digests were pushed to every --repo by the build).
|
||||
#
|
||||
# Env: IMAGETOOLS overrides the command (default: "docker buildx imagetools");
|
||||
# Env: ALLOW_AMD64_ONLY=true lets the guard pass; VERIFY_ARCH overrides the verifier command
|
||||
# (tests use a stub); IMAGETOOLS overrides the command (default: "docker buildx imagetools");
|
||||
# the test suite points it at a stub.
|
||||
set -euo pipefail
|
||||
|
||||
IMAGETOOLS=${IMAGETOOLS:-docker buildx imagetools}
|
||||
amd64=""; arm64=""; outcome="skipped"; builder=""
|
||||
repos=(); tags=()
|
||||
repos=(); tags=(); vbins=(); guard=0
|
||||
HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
|
||||
die() { echo "assemble-multiarch-index: $*" >&2; exit 1; }
|
||||
warn() { echo "::warning::assemble-multiarch-index: $*"; }
|
||||
@@ -41,6 +51,8 @@ while [ $# -gt 0 ]; do
|
||||
--repo) repos+=("${2-}"); shift 2 ;;
|
||||
--tag) tags+=("${2-}"); shift 2 ;;
|
||||
--builder) builder=${2-}; shift 2 ;;
|
||||
--verify-bin) vbins+=("${2-}"); shift 2 ;;
|
||||
--guard-existing-arm64) guard=1; shift ;;
|
||||
*) die "unknown argument: $1" ;;
|
||||
esac
|
||||
done
|
||||
@@ -80,6 +92,40 @@ else
|
||||
done
|
||||
fi
|
||||
|
||||
# ELF machine-type check (labels alone do not prove the binaries are of that architecture).
|
||||
if [ ${#vbins[@]} -gt 0 ]; then
|
||||
# shellcheck disable=SC2206
|
||||
verify=(${VERIFY_ARCH:-python3 -I "$HERE/verify-image-arch.py"})
|
||||
vargs=(); for b in "${vbins[@]}"; do vargs+=(--bin "$b"); done
|
||||
for r in "${repos[@]}"; do
|
||||
"${verify[@]}" --image "$r@$amd64" --platform linux/amd64 "${vargs[@]}" \
|
||||
|| die "$r@$amd64 failed the x86-64 ELF check; refusing to publish"
|
||||
if [ "$use_arm64" = 1 ]; then
|
||||
if ! "${verify[@]}" --image "$r@$arm64" --platform linux/arm64 "${vargs[@]}"; then
|
||||
warn "$r@$arm64 failed the AArch64 ELF check: publishing amd64-only"
|
||||
use_arm64=0; break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Never silently replace a multi-arch tag by an amd64-only one.
|
||||
if [ "$guard" = 1 ] && [ "$use_arm64" = 0 ] && [ "${ALLOW_AMD64_ONLY:-false}" != true ]; then
|
||||
for r in "${repos[@]}"; do for t in "${tags[@]}"; do
|
||||
rc=0; info=$(IMAGETOOLS=$IMAGETOOLS "$HERE/index-platforms.sh" "$r:$t") || rc=$?
|
||||
case "$rc" in
|
||||
0) ;;
|
||||
3) info="not found" ;;
|
||||
*) echo "::error::assemble-multiarch-index: cannot tell whether $r:$t is multi-arch; refusing to overwrite it (fail closed)" >&2; exit 1 ;;
|
||||
esac
|
||||
case "$info" in
|
||||
*linux/arm64*)
|
||||
echo "::error::assemble-multiarch-index: $r:$t has an arm64 entry but this build has none (arm64 outcome '$outcome'); publishing amd64-only would drop it. Nothing published. amd64 digest of this build: $amd64. Fix: re-dispatch only=<leg>, or re-run with allow_amd64_only=true and then restore arm64 with the arm64-attach workflow." >&2
|
||||
exit 1 ;;
|
||||
esac
|
||||
done; done
|
||||
fi
|
||||
|
||||
for r in "${repos[@]}"; do
|
||||
targs=(); for t in "${tags[@]}"; do targs+=(-t "$r:$t"); done
|
||||
srcs=("$r@$amd64"); [ "$use_arm64" = 1 ] && srcs+=("$r@$arm64")
|
||||
|
||||
Reference in new issue
Block a user