Handle docker hangs and subscription mismatch on acr login (#4653)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
Azure SDK Bot 2023-05-24 15:45:14 -07:00 committed by GitHub
parent 77d894299e
commit 8f2375dad5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}
}
@ -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
}