Skip to content

Commit bec1acd

Browse files
newbe36524claude
andcommitted
fix: Add ACR propagation delay for image verification
Add waiting loops in both Azure ACR and Aliyun ACR verification steps to handle registry propagation delays. The docker manifest inspect command now retries up to 10 times with 3 second intervals before failing. This prevents false negatives when images are pushed but manifests are not yet available for inspection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3f6bf4a commit bec1acd

1 file changed

Lines changed: 65 additions & 2 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,38 @@ jobs:
322322
323323
echo "Verifying images in registry..."
324324
325+
# Wait for ACR propagation - manifests may take a few seconds to be available
326+
echo "Waiting for ACR to propagate images..."
327+
for TAG in "${VERSION}" "${MAJOR}.${MINOR}" "${MAJOR}"; do
328+
ATTEMPT=0
329+
MAX_ATTEMPTS=10
330+
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
331+
# Extract architecture list from manifest using jq
332+
# jq is required for parsing JSON output of docker manifest inspect
333+
ARCHITECTURES=$(docker manifest inspect ${REGISTRY}/${IMAGE_NAME}:${TAG} 2>/dev/null | jq -r '.[].Platform[].architecture' 2>/dev/null || echo "")
334+
335+
if [ -n "${ARCHITECTURES}" ]; then
336+
echo "✓ Tag ${TAG} is ready (attempt $((ATTEMPT + 1))/$MAX_ATTEMPTS)"
337+
break
338+
fi
339+
340+
ATTEMPT=$((ATTEMPT + 1))
341+
if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then
342+
echo "Tag ${TAG} not ready yet, waiting... (attempt $ATTEMPT/$MAX_ATTEMPTS)"
343+
sleep 3
344+
fi
345+
done
346+
347+
if [ -z "${ARCHITECTURES}" ]; then
348+
echo "::error::Timed out waiting for tag ${TAG} to become available in ACR"
349+
echo "This may indicate a propagation delay or the image was not successfully pushed."
350+
exit 1
351+
fi
352+
done
353+
354+
echo "All tags verified to be available in ACR"
355+
echo ""
356+
325357
# Parse version parts for tag verification
326358
MAJOR=$(echo ${VERSION} | cut -d. -f1)
327359
MINOR=$(echo ${VERSION} | cut -d. -f2)
@@ -334,7 +366,7 @@ jobs:
334366
335367
# Verify image architectures for each tag
336368
for TAG in "${VERSION}" "${MAJOR}.${MINOR}" "${MAJOR}"; do
337-
echo "Verifying tag: ${TAG}"
369+
echo "Verifying architectures for tag: ${TAG}"
338370
339371
# Extract architecture list from manifest using jq
340372
# jq is required for parsing the JSON output of docker manifest inspect
@@ -478,6 +510,37 @@ jobs:
478510
479511
echo "Verifying images in Aliyun ACR..."
480512
513+
# Wait for Aliyun ACR propagation - manifests may take a few seconds to be available
514+
echo "Waiting for Aliyun ACR to propagate images..."
515+
for TAG in "${TAGS[@]}"; do
516+
ATTEMPT=0
517+
MAX_ATTEMPTS=10
518+
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
519+
# Extract architecture list from manifest using jq
520+
ARCHITECTURES=$(docker manifest inspect ${ALIYUN_IMAGE_NAME}:${TAG} 2>/dev/null | jq -r '.[].Platform[].architecture' 2>/dev/null || echo "")
521+
522+
if [ -n "${ARCHITECTURES}" ]; then
523+
echo "✓ Tag ${TAG} is ready (attempt $((ATTEMPT + 1))/$MAX_ATTEMPTS)"
524+
break
525+
fi
526+
527+
ATTEMPT=$((ATTEMPT + 1))
528+
if [ $ATTEMPT -lt $MAX_ATTEMPTS ]; then
529+
echo "Tag ${TAG} not ready yet, waiting... (attempt $ATTEMPT/$MAX_ATTEMPTS)"
530+
sleep 3
531+
fi
532+
done
533+
534+
if [ -z "${ARCHITECTURES}" ]; then
535+
echo "::error::Timed out waiting for tag ${TAG} to become available in Aliyun ACR"
536+
echo "This may indicate a propagation delay or the image was not successfully pushed."
537+
exit 1
538+
fi
539+
done
540+
541+
echo "All tags verified to be available in Aliyun ACR"
542+
echo ""
543+
481544
# Multi-architecture verification for Aliyun ACR:
482545
# - Same requirements as Azure ACR: both amd64 and arm64 must be present
483546
# - Verified for all pushed tags: version, major.minor, major, and latest (if stable)
@@ -491,7 +554,7 @@ jobs:
491554
492555
# Verify each tag's architectures
493556
for TAG in "${TAGS[@]}"; do
494-
echo "Verifying tag: ${TAG}"
557+
echo "Verifying architectures for tag: ${TAG}"
495558
496559
# Extract architecture list from manifest using jq
497560
ARCHITECTURES=$(docker manifest inspect ${ALIYUN_IMAGE_NAME}:${TAG} 2>/dev/null | jq -r '.[].Platform[].architecture' 2>/dev/null || echo "")

0 commit comments

Comments
 (0)