From 3f70a92f0cbb3ae002c85810a3cca70a7d522bf6 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Fri, 5 Nov 2021 12:06:44 -0700 Subject: [PATCH] updating the original container create to a retry --- eng/common/testproxy/docker-start-proxy.ps1 | 17 ++++++++++++++++- eng/common/testproxy/test-proxy-docker.yml | 20 +------------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/eng/common/testproxy/docker-start-proxy.ps1 b/eng/common/testproxy/docker-start-proxy.ps1 index 4137ae2aff..1419cc1496 100644 --- a/eng/common/testproxy/docker-start-proxy.ps1 +++ b/eng/common/testproxy/docker-start-proxy.ps1 @@ -64,9 +64,24 @@ if ($Mode -eq "start"){ } # else we need to create it else { + $attempts = 0 Write-Host "Attempting creation of Docker host $CONTAINER_NAME" Write-Host "docker container create -v `"${root}:${Initial}/etc/testproxy`" $LinuxContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage" - docker container create -v "${root}:${Initial}/etc/testproxy" $LinuxContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage + while($attempts -lt 3){ + docker container create -v "${root}:${Initial}/etc/testproxy" $LinuxContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage + + if($LASTEXITCODE -ne 0){ + continue + } + else { + break + } + $attempts += 1 + } + + if($LASTEXITCODE -ne 0){ + exit(1) + } } Write-Host "Attempting start of Docker host $CONTAINER_NAME" diff --git a/eng/common/testproxy/test-proxy-docker.yml b/eng/common/testproxy/test-proxy-docker.yml index c7e106144b..e4e4b2c8cd 100644 --- a/eng/common/testproxy/test-proxy-docker.yml +++ b/eng/common/testproxy/test-proxy-docker.yml @@ -6,27 +6,9 @@ steps: $(Build.SourcesDirectory)/eng/common/scripts/trust-proxy-certificate.ps1 displayName: 'Language Specific Certificate Trust' - # windows has a startup bug where the service is unavailable. See Azure/azure-sdk-tools#2122 - pwsh: | docker info - - # if info failed, we need to restart the service and start docker desktop - if($LASTEXITCODE -ne 0) - { - # Ensure the service is running - Get-Service com.docker.service | Restart-Service - - # Start docker desktop - $dockerExeLocation = (Get-Command docker).Source - - # on windows, docker.exe is shipped here: - # C:\Program Files\Docker\Docker\resources\bin\docker.exe - # Docker desktop lives in the same base path, just up a couple levels: - # C:\Program Files\Docker\Docker\Docker Desktop.exe - $dockerDesktopLocation = Resolve-Path (Join-Path -Path $dockerExeLocation -ChildPath "../../../Docker Desktop.exe") - &$dockerDesktopLocation - } - condition: and(succeededOrFailed(), eq(variables['Agent.OS'],'Windows_NT')) + displayName: 'Dump active docker information' - pwsh: | $(Build.SourcesDirectory)/eng/common/testproxy/docker-start-proxy.ps1 -Mode start -TargetFolder "${{ parameters.rootFolder }}"