From 5a185c9575f8aa0342c4bf7426a8f8dc6a3f59a1 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 19 Nov 2024 13:07:55 -0800 Subject: [PATCH] retry logic on push in case of 502 errors (#136) --- build.ps1 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5f14e00..fa8c9a9 100644 --- a/build.ps1 +++ b/build.ps1 @@ -117,6 +117,24 @@ ForEach($platform in $platforms.Split(",")) { if($push -eq $true) { ForEach($t in ($tags + ($tag -ne '' ? @("$tag") : @()))) { - exec buildah manifest push --all "$manifest" "docker://$t" - } + $retries = 0 + $maxRetries = 3 + $success = $false + + while(-not $success -and $retries -lt $maxRetries) { + try { + exec buildah manifest push --all "$manifest" "docker://$t" + $success = $true + } catch { + $retries++ + Write-Host "Error encountered during push. Retrying... ($retries/$maxRetries)" + Start-Sleep -Seconds 2 + } + } + + if(-not $success) { + Write-Host "Failed to push after $maxRetries attempts." + exit 1 + } + } }