Skip to content

Commit

Permalink
Handle docker hangs and subscription mismatch on acr login (#6235)
Browse files Browse the repository at this point in the history
  • Loading branch information
benbp authored May 24, 2023
1 parent 90ff2f1 commit 1253bc3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function Login([string]$subscription, [string]$clusterGroup, [switch]$skipPushIm
if (!$skipPushImages) {
$registry = RunOrExitOnFailure az acr list -g $clusterGroup --subscription $subscription -o json
$registryName = ($registry | ConvertFrom-Json).name
RunOrExitOnFailure az acr login -n $registryName
RunOrExitOnFailure az acr login -n $registryName --subscription $subscription
}
}

Expand Down Expand Up @@ -387,6 +387,21 @@ function CheckDependencies()
throw "Please update helm to version >= $MIN_HELM_VERSION (current version: $helmVersionString)`nAdditional information for updating helm version can be found here: https://helm.sh/docs/intro/install/"
}

# Ensure docker is running via command and handle command hangs
if (!$skipPushImages) {
$LastErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
$job = Start-Job { docker ps; return $LASTEXITCODE }
$result = $job | Wait-Job -Timeout 5 | Receive-Job

$ErrorActionPreference = $LastErrorActionPreference
$job | Remove-Job -Force

if (($result -eq $null -and $job.State -ne "Completed") -or ($result | Select -Last 1) -ne 0) {
throw "Docker does not appear to be running. Start/restart docker."
}
}

if ($shouldError) {
exit 1
}
Expand Down

0 comments on commit 1253bc3

Please sign in to comment.