Skip to content

Commit 58357e2

Browse files
committed
fix(ci): bound the promoted-tag wait by elapsed time and each ECR read by a timeout
1 parent d038d9a commit 58357e2

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎.github/scripts/get-ecr-image-digest.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if [ -n "$ALLOW_MISSING" ] && [ "$ALLOW_MISSING" != '--allow-missing' ]; then
99
exit 1
1010
fi
1111
export AWS_PAGER=''
12-
aws ecr batch-get-image --repository-name "$REPOSITORY" --image-ids imageTag="$TAG" --output json |
12+
aws --cli-connect-timeout 10 --cli-read-timeout 20 ecr batch-get-image --repository-name "$REPOSITORY" --image-ids imageTag="$TAG" --output json |
1313
ALLOW_MISSING="$ALLOW_MISSING" python3 -c '
1414
import json, os, re, sys
1515
response = json.load(sys.stdin)

‎.github/scripts/promote-app-image.sh‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ MANIFEST=$(docker buildx imagetools create --dry-run -t "$REGISTRY/$REPOSITORY:$
1717
DIGEST="sha256:$(printf '%s' "$MANIFEST" | sha256sum | cut -d' ' -f1)"
1818
EPOCH=$(date +%s)
1919
bash "$SCRIPT_DIR/promote-image.sh" "$REGISTRY" "$REPOSITORY" "$SOURCE_TAG" "$DEPLOY_TAG" "$RELEASE_TAG"
20-
for attempt in $(seq 1 20); do
21-
[ "$(bash "$SCRIPT_DIR/get-ecr-image-digest.sh" "$REPOSITORY" "$DEPLOY_TAG" --allow-missing)" = "$DIGEST" ] && break
22-
if [ "$attempt" -eq 20 ]; then
23-
echo "ERROR: $DEPLOY_TAG never resolved to the pushed $DIGEST; cutover cannot be correlated" >&2
20+
deadline=$(( $(date +%s) + 60 ))
21+
until [ "$(bash "$SCRIPT_DIR/get-ecr-image-digest.sh" "$REPOSITORY" "$DEPLOY_TAG" --allow-missing)" = "$DIGEST" ]; do
22+
if [ "$(date +%s)" -ge "$deadline" ]; then
23+
echo "ERROR: $DEPLOY_TAG did not resolve to the pushed $DIGEST within 60s; cutover cannot be correlated" >&2
2424
exit 1
2525
fi
2626
sleep 3

0 commit comments

Comments
 (0)