Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wait time to retries in sourcelink validation #7758

Merged
merged 1 commit into from
Aug 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions eng/common/post-build/sourcelink-validation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ $global:RepoFiles = @{}
$MaxParallelJobs = 16

$MaxRetries = 5
$RetryWaitTimeInSeconds = 30

# Wait time between check for system load
$SecondsBetweenLoadChecks = 10
Expand Down Expand Up @@ -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]
Expand All @@ -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
michellemcdaniel marked this conversation as resolved.
Show resolved Hide resolved
}
}
catch {
Expand All @@ -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
Expand Down