Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 2219 (Azure#21622)
Browse files Browse the repository at this point in the history
* adding retry to docker container start

Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>
  • Loading branch information
azure-sdk and scbedd authored Nov 6, 2021
1 parent 519dcca commit e7ce98f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
24 changes: 23 additions & 1 deletion eng/common/testproxy/docker-start-proxy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,31 @@ 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){
$attempts += 1
Start-Sleep -s 10

if($attempts -lt 3){
Write-Host "Attempt $attempts failed. Retrying."
}

continue
}
else {
break
}
}

if($LASTEXITCODE -ne 0){
Write-Host "Unable to successfully create docker container. Exiting."
exit(1)
}
}

Write-Host "Attempting start of Docker host $CONTAINER_NAME"
Expand Down
4 changes: 4 additions & 0 deletions eng/common/testproxy/test-proxy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ steps:
$(Build.SourcesDirectory)/eng/common/scripts/trust-proxy-certificate.ps1
displayName: 'Language Specific Certificate Trust'
- pwsh: |
docker info
displayName: 'Dump active docker information'
- pwsh: |
$(Build.SourcesDirectory)/eng/common/testproxy/docker-start-proxy.ps1 -Mode start -TargetFolder "${{ parameters.rootFolder }}"
displayName: 'Run the docker container'
Expand Down

0 comments on commit e7ce98f

Please sign in to comment.