diff --git a/src/ACR-SyncTool.csproj b/src/ACR-SyncTool.csproj
index 56c6eeb..d90e2e2 100644
--- a/src/ACR-SyncTool.csproj
+++ b/src/ACR-SyncTool.csproj
@@ -26,12 +26,13 @@
+
-
+
diff --git a/src/DockerClient/DockerTagClient.cs b/src/DockerClient/DockerTagClient.cs
index d5110b9..cfc7b62 100644
--- a/src/DockerClient/DockerTagClient.cs
+++ b/src/DockerClient/DockerTagClient.cs
@@ -44,7 +44,19 @@ private async Task> GetTagsRecursive(string url)
var request = CreateRequest(url);
- var response = await httpClient.SendAsync(request);
+ HttpStatusCode[] httpStatusCodesWorthRetrying = {
+ HttpStatusCode.RequestTimeout, // 408
+ HttpStatusCode.TooManyRequests, // 429
+ HttpStatusCode.InternalServerError, // 500
+ HttpStatusCode.BadGateway, // 502
+ HttpStatusCode.ServiceUnavailable, // 503
+ HttpStatusCode.GatewayTimeout // 504
+ };
+
+ var response = await Policy
+ .HandleResult(r => httpStatusCodesWorthRetrying.Contains(r.StatusCode))
+ .WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)))
+ .ExecuteAsync(async () => await httpClient.SendAsync(request));
if (response.StatusCode == HttpStatusCode.Unauthorized)
{
@@ -67,8 +79,7 @@ private async Task> GetTagsRecursive(string url)
var pageQuery = matches.Groups[1].Value;
- // Delay recursion to prevent "429 Too Many Requests" errors
- await Task.Delay(TimeSpan.FromSeconds(10));
+ await Task.Delay(TimeSpan.FromSeconds(2));
var newTags = await GetTagsRecursive($"{(Https ? "https" : "http")}://{host}{pageQuery}");
diff --git a/src/GlobalUsings.cs b/src/GlobalUsings.cs
index 00a318a..d7612ba 100644
--- a/src/GlobalUsings.cs
+++ b/src/GlobalUsings.cs
@@ -1,31 +1,32 @@
-global using ACR_SyncTool.DockerClient.Authentication;
+global using ACR_SyncTool.DockerClient;
+global using ACR_SyncTool.DockerClient.Authentication;
global using ACR_SyncTool.DockerClient.Extensionis;
global using ACR_SyncTool.DockerClient.OAuth;
-global using ACR_SyncTool.DockerClient;
global using ACR_SyncTool.Models;
global using Azure.Containers.ContainerRegistry;
global using Azure.Identity;
-global using Docker.DotNet.Models;
global using Docker.DotNet;
-global using Microsoft.Extensions.Configuration.Json;
+global using Docker.DotNet.Models;
global using Microsoft.Extensions.Configuration;
+global using Microsoft.Extensions.Configuration.Json;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
+global using Polly;
+global using System;
global using System.Collections.Generic;
global using System.Diagnostics;
global using System.IO;
global using System.Linq;
+global using System.Net;
+global using System.Net.Http;
global using System.Net.Http.Headers;
global using System.Net.Http.Json;
-global using System.Net.Http;
-global using System.Net;
global using System.Security.Authentication;
global using System.Security.Cryptography.X509Certificates;
-global using System.Text.Json.Serialization;
+global using System.Text;
global using System.Text.Json;
+global using System.Text.Json.Serialization;
global using System.Text.RegularExpressions;
-global using System.Text;
-global using System.Threading.Tasks;
global using System.Threading;
-global using System;
\ No newline at end of file
+global using System.Threading.Tasks;