Skip to content

Commit d310213

Browse files
authored
Add retry to install mingw (microsoft#1636)
Integration test often fails because of mingw installation failure, which in turn appears to be a web-request issues. Adding rety and backoff/sleep to resolve issue. Signed-off-by: Hamza El-Saawy <[email protected]>
1 parent 9f4ddc6 commit d310213

1 file changed

Lines changed: 62 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ jobs:
168168

169169
- name: Test rego security policy
170170
run: go test --tags=rego -timeout=30m -mod=mod -gcflags=all=-d=checkptr -v ./pkg/securitypolicy
171-
171+
172172
- name: Test rego policy interpreter
173173
run: go test -mod=mod -gcflags=all=-d=checkptr -v ./internal/regopolicyinterpreter
174174

@@ -243,12 +243,72 @@ jobs:
243243
with:
244244
path: src/github.com/Microsoft/hcsshim
245245

246+
- name: Install crictl
247+
shell: powershell
248+
run: |
249+
$VerbosePreference = 'Continue'
250+
$ErrorActionPreference = 'Stop'
251+
252+
$crictlVersion = 'v1.24.2'
253+
$url = "https://github.com/kubernetes-sigs/cri-tools/releases/download/${crictlVersion}/crictl-${crictlVersion}-windows-amd64.tar.gz"
254+
curl.exe -L --no-progress-meter -o c:\crictl.tar.gz $url
255+
tar.exe xf c:\crictl.tar.gz -C "${{ github.workspace }}/bin"
256+
257+
if ( $LASTEXITCODE ) {
258+
Write-Output '::error::Could not install crictl.'
259+
exit $LASTEXITCODE
260+
}
261+
262+
- name: Install mingw
263+
shell: powershell
264+
run: |
265+
$VerbosePreference = 'Continue'
266+
# dont set $ErrorActionPreference since we want to allow choco install to fail later on
267+
268+
Write-Output '::group::Update chocolaty'
269+
choco upgrade -y chocolatey
270+
Write-Output '::endgroup::'
271+
272+
if ( $LASTEXITCODE ) {
273+
Write-Output '::error::Could not update chocolatey.'
274+
exit $LASTEXITCODE
275+
}
276+
277+
Write-Output 'Install mingw'
278+
# Install sometimes fails when downloading mingw zip from source-forge with:
279+
# "ERROR: The remote file either doesn't exist, is unauthorized, or is forbidden for url"
280+
# Issue is with accessing from source-forge, which version 10.3+ do not use, but cannot upgrade versions.
281+
282+
# Add retry and backoff
283+
foreach ( $i in 1..3 ) {
284+
Write-Output "::group::Attempt $i"
285+
if ( $i -gt 1 ) {
286+
# remove any left-over state
287+
choco uninstall -y --no-progress --force mingw
288+
289+
Write-Output 'Sleeping for 2 seconds'
290+
Sleep -Seconds 2
291+
}
292+
293+
choco install -y --no-progress --stop-on-first-failure --force mingw --allow-downgrade --version 10.2.0
294+
Write-Output '::endgroup::'
295+
if ( -not $LASTEXITCODE ) {
296+
Write-Output "Attempt $i succeeded (exit code: $LASTEXITCODE)"
297+
break
298+
}
299+
Write-Output "::warning title=mingw::Attempt $i failed (exit code: $LASTEXITCODE)"
300+
}
301+
302+
if ( $LASTEXITCODE ) {
303+
Write-Output "::error::Could not install mingw after $i attempts."
304+
exit $LASTEXITCODE
305+
}
306+
246307
- name: Build binaries
247308
shell: bash
248309
working-directory: src/github.com/containerd/containerd
249310
run: |
250311
set -o xtrace
251-
choco install mingw --version 10.2.0 --allow-downgrade
252312
mingw32-make.exe binaries
253313
script/setup/install-cni-windows
254314
@@ -258,12 +318,6 @@ jobs:
258318
run: |
259319
go build -mod vendor -o "${{ github.workspace }}/src/github.com/containerd/containerd/bin/containerd-shim-runhcs-v1.exe" .\cmd\containerd-shim-runhcs-v1
260320
261-
- name: Get crictl tool
262-
shell: powershell
263-
run: |
264-
curl.exe -L "https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.24.2/crictl-v1.24.2-windows-amd64.tar.gz" -o c:\crictl.tar.gz
265-
tar xf c:\crictl.tar.gz -C "${{ github.workspace }}/bin"
266-
267321
- name: Run containerd integration tests
268322
shell: bash
269323
working-directory: src/github.com/containerd/containerd

0 commit comments

Comments
 (0)