From f8f7d3f512e1b616ff832ef194256522c556b028 Mon Sep 17 00:00:00 2001 From: Michelle McDaniel Date: Mon, 16 Aug 2021 14:23:27 -0700 Subject: [PATCH] retry wait --- eng/common/post-build/sourcelink-validation.ps1 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/eng/common/post-build/sourcelink-validation.ps1 b/eng/common/post-build/sourcelink-validation.ps1 index 85c89861719..3b6fc953337 100644 --- a/eng/common/post-build/sourcelink-validation.ps1 +++ b/eng/common/post-build/sourcelink-validation.ps1 @@ -17,6 +17,7 @@ $global:RepoFiles = @{} $MaxParallelJobs = 16 $MaxRetries = 5 +$RetryWaitTimeInSeconds = 30 # Wait time between check for system load $SecondsBetweenLoadChecks = 10 @@ -99,9 +100,9 @@ $ValidatePackage = { $Status = 200 $Cache = $using:RepoFiles - $totalRetries = 0 + $attempts = 0 - while ($totalRetries -lt $using:MaxRetries) { + while ($attempts -lt $using:MaxRetries) { if ( !($Cache.ContainsKey($FilePath)) ) { try { $Uri = $Link -as [System.URI] @@ -113,7 +114,7 @@ $ValidatePackage = { else { # If it's not a github link, we want to break out of the loop and not retry. $Status = 0 - $totalRetries = $using:MaxRetries + $attempts = $using:MaxRetries } } catch { @@ -123,9 +124,15 @@ $ValidatePackage = { } if ($Status -ne 200) { - $totalRetries++ + $attempts++ - if ($totalRetries -ge $using:MaxRetries) { + if ($attempts -lt $using:MaxRetries) + { + $attemptsLeft = $using:MaxRetries - $attempts + Write-Warning "Download failed, $attemptsLeft attempts remaining, will retry in $using:RetryWaitTimeInSeconds seconds" + Start-Sleep -Seconds $using:RetryWaitTimeInSeconds + } + else { if ($NumFailedLinks -eq 0) { if ($FailedFiles.Value -eq 0) { Write-Host