Skip to content

Commit

Permalink
Retry k3d image import in workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Manno committed Sep 19, 2023
1 parent b9bcb1a commit cc47d56
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
22 changes: 22 additions & 0 deletions .github/scripts/k3d-import-retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -euxo pipefail

container=${1:-k3d-upstream}
name=${2:-fleet}
shift
shift

echo "Run k3d import with \"$*\" and retry if '$name' is not found in 'critcl images' output"

i=0
while ! ( docker exec "$container"-server-0 /bin/crictl images | grep -q "$name" ); do
i=$((i + 1))
if (( i > 3 )); then
echo "failed to import images"
exit 1
fi
k3d image import "$@"
# crictl images doesn't show the image immediately after import
sleep 20
done
6 changes: 4 additions & 2 deletions .github/workflows/e2e-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ jobs:
-
name: Import Images Into k3d
run: |
k3d image import rancher/fleet:dev rancher/fleet-agent:dev
k3d image import nginx-git:test nginx-git:test
./.github/scripts/k3d-import-retry.sh k3d-k3s-default fleet \
rancher/fleet:dev rancher/fleet-agent:dev
./.github/scripts/k3d-import-retry.sh k3d-k3s-default nginx-git \
nginx-git:test nginx-git:test
-
name: Set Up Tmate Debug Session
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.enable_tmate == 'true' }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/e2e-multicluster-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ jobs:
-
name: Import Images Into k3d
run: |
k3d image import rancher/fleet:dev rancher/fleet-agent:dev -c upstream
k3d image import rancher/fleet-agent:dev -c downstream
./.github/scripts/k3d-import-retry.sh k3d-upstream fleet \
rancher/fleet:dev rancher/fleet-agent:dev -c upstream
./.github/scripts/k3d-import-retry.sh k3d-downstream fleet-agent \
rancher/fleet-agent:dev -c downstream
-
name: Set Up Tmate Debug Session
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.enable_tmate == 'true' }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/fleet-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ jobs:
-
name: Import Images Into k3d
run: |
k3d image import rancher/fleet:dev rancher/fleet-agent:dev -c upstream
./.github/scripts/k3d-import-retry.sh k3d-upstream fleet \
rancher/fleet:dev rancher/fleet-agent:dev -c upstream
-
name: Verify Example Workload
run: |
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ jobs:
-
name: Import Images Into k3d
run: |
k3d image import rancher/fleet:dev rancher/fleet-agent:dev
k3d image import nginx-git:test nginx-git:test
./.github/scripts/k3d-import-retry.sh k3d-k3s-default fleet \
rancher/fleet:dev rancher/fleet-agent:dev
./.github/scripts/k3d-import-retry.sh k3d-k3s-default nginx-git \
nginx-git:test
-
name: Deploy Fleet
run: |
Expand Down

0 comments on commit cc47d56

Please sign in to comment.