Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:
- run: make openapi-generated-check
- run: make release-workflow-check
- run: bash scripts/ci/resolve-cli-build-env.test.sh
- run: bash scripts/ci/retry-image-pull.test.sh
- run: make lint
- run: make test
- run: go build ./...
Expand All @@ -110,6 +111,8 @@ jobs:
run: |
set -euo pipefail
docker manifest inspect kong/volcano:local-nightly >/dev/null
- name: Pre-pull AppConfig agent with retries
run: bash scripts/ci/retry-image-pull.sh docker compose -f internal/localmode/assets/docker-compose.template.yml -p volcano pull appconfig-agent
- name: Run local-mode CLI contract smoke
env:
VOLCANO_IMAGE: kong/volcano:local-nightly
Expand Down
18 changes: 18 additions & 0 deletions scripts/ci/retry-image-pull.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail

if [ "$#" -eq 0 ]; then
echo "usage: ${0##*/} <pull command>..." >&2
exit 2
fi

for attempt in {1..4}; do
if "$@"; then
exit 0
fi
if [ "$attempt" -eq 4 ]; then
echo "image pull failed after $attempt attempts: $*" >&2
exit 1
fi
sleep "${IMAGE_PULL_RETRY_DELAY_SECONDS:-15}"
done
20 changes: 20 additions & 0 deletions scripts/ci/retry-image-pull.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

root="$(cd "$(dirname "$0")/../.." && pwd)"
state="$(mktemp)"
trap 'rm -f "$state"' EXIT

pull='n=$(cat "$STATE"); n=$((n + 1)); echo "$n" > "$STATE"; [ "$n" -ge "$SUCCEED_ON" ]'
echo 0 > "$state"
STATE="$state" SUCCEED_ON=3 IMAGE_PULL_RETRY_DELAY_SECONDS=0 \
bash "$root/scripts/ci/retry-image-pull.sh" bash -c "$pull"
[ "$(cat "$state")" -eq 3 ]

echo 0 > "$state"
if STATE="$state" SUCCEED_ON=99 IMAGE_PULL_RETRY_DELAY_SECONDS=0 \
bash "$root/scripts/ci/retry-image-pull.sh" bash -c "$pull"; then
echo 'accepted failed pull' >&2
exit 1
fi
[ "$(cat "$state")" -eq 4 ]
Loading