Skip to content

Commit 6e3864a

Browse files
azure-sdkbenbp
andauthored
Handle docker hangs and subscription mismatch on acr login (Azure#35144)
Co-authored-by: Ben Broderick Phillips <[email protected]>
1 parent e7aea9f commit 6e3864a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function Login([string]$subscription, [string]$clusterGroup, [switch]$skipPushIm
7676
if (!$skipPushImages) {
7777
$registry = RunOrExitOnFailure az acr list -g $clusterGroup --subscription $subscription -o json
7878
$registryName = ($registry | ConvertFrom-Json).name
79-
RunOrExitOnFailure az acr login -n $registryName
79+
RunOrExitOnFailure az acr login -n $registryName --subscription $subscription
8080
}
8181
}
8282

@@ -387,6 +387,21 @@ function CheckDependencies()
387387
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/"
388388
}
389389

390+
# Ensure docker is running via command and handle command hangs
391+
if (!$skipPushImages) {
392+
$LastErrorActionPreference = $ErrorActionPreference
393+
$ErrorActionPreference = 'Continue'
394+
$job = Start-Job { docker ps; return $LASTEXITCODE }
395+
$result = $job | Wait-Job -Timeout 5 | Receive-Job
396+
397+
$ErrorActionPreference = $LastErrorActionPreference
398+
$job | Remove-Job -Force
399+
400+
if (($result -eq $null -and $job.State -ne "Completed") -or ($result | Select -Last 1) -ne 0) {
401+
throw "Docker does not appear to be running. Start/restart docker."
402+
}
403+
}
404+
390405
if ($shouldError) {
391406
exit 1
392407
}

0 commit comments

Comments
 (0)