Skip to content

Commit 3b9762f

Browse files
azure-sdkscbedd
andauthored
Sync eng/common directory with azure-sdk-tools for PR 2219 (#924)
* adding retry to docker start Co-authored-by: scbedd <[email protected]>
1 parent 1a0404f commit 3b9762f

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

eng/common/testproxy/docker-start-proxy.ps1

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,31 @@ if ($Mode -eq "start"){
6464
}
6565
# else we need to create it
6666
else {
67+
$attempts = 0
6768
Write-Host "Attempting creation of Docker host $CONTAINER_NAME"
6869
Write-Host "docker container create -v `"${root}:${Initial}/etc/testproxy`" $LinuxContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage"
69-
docker container create -v "${root}:${Initial}/etc/testproxy" $LinuxContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage
70+
while($attempts -lt 3){
71+
docker container create -v "${root}:${Initial}/etc/testproxy" $LinuxContainerArgs -p 5001:5001 -p 5000:5000 --name $CONTAINER_NAME $SelectedImage
72+
73+
if($LASTEXITCODE -ne 0){
74+
$attempts += 1
75+
Start-Sleep -s 10
76+
77+
if($attempts -lt 3){
78+
Write-Host "Attempt $attempts failed. Retrying."
79+
}
80+
81+
continue
82+
}
83+
else {
84+
break
85+
}
86+
}
87+
88+
if($LASTEXITCODE -ne 0){
89+
Write-Host "Unable to successfully create docker container. Exiting."
90+
exit(1)
91+
}
7092
}
7193

7294
Write-Host "Attempting start of Docker host $CONTAINER_NAME"

eng/common/testproxy/test-proxy-docker.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ steps:
66
$(Build.SourcesDirectory)/eng/common/scripts/trust-proxy-certificate.ps1
77
displayName: 'Language Specific Certificate Trust'
88
9+
- pwsh: |
10+
docker info
11+
displayName: 'Dump active docker information'
12+
913
- pwsh: |
1014
$(Build.SourcesDirectory)/eng/common/testproxy/docker-start-proxy.ps1 -Mode start -TargetFolder "${{ parameters.rootFolder }}"
1115
displayName: 'Run the docker container'

0 commit comments

Comments
 (0)