From 6ad23bfca1709b10bce3adffc33e1006a5867692 Mon Sep 17 00:00:00 2001 From: Michael Stuckey Date: Fri, 13 Aug 2021 14:54:48 -0700 Subject: [PATCH 1/3] Retry PublishArtifacts download on all exceptions --- .../src/PublishArtifactsInManifestBase.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs index 86af0164d0a..e4cd664772a 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs @@ -957,9 +957,10 @@ public async Task DownloadFileAsync( return true; } - catch (Exception toStore) when (toStore is HttpRequestException || toStore is TaskCanceledException || toStore is SocketException) + catch (Exception toStore) { mostRecentlyCaughtException = toStore; + Log.LogMessage(MessageImportance.Normal, $"Download failed due to {toStore.GetType().FullName}: {toStore.Message}"); return false; } }).ConfigureAwait(false); From 347bff201406a37c5a4cef9a94881fc88b14f2e9 Mon Sep 17 00:00:00 2001 From: Michael Stuckey Date: Fri, 13 Aug 2021 15:18:25 -0700 Subject: [PATCH 2/3] Remove log line, fixup exception reporting --- .../src/PublishArtifactsInManifestBase.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs index e4cd664772a..9e31325f149 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifestBase.cs @@ -960,7 +960,6 @@ public async Task DownloadFileAsync( catch (Exception toStore) { mostRecentlyCaughtException = toStore; - Log.LogMessage(MessageImportance.Normal, $"Download failed due to {toStore.GetType().FullName}: {toStore.Message}"); return false; } }).ConfigureAwait(false); @@ -968,7 +967,7 @@ public async Task DownloadFileAsync( if (!success) { throw new Exception( - $"Failed to download local file '{path}' after {RetryHandler.MaxAttempts} attempts. See inner exception for details, {mostRecentlyCaughtException}"); + $"Failed to download local file '{path}' after {RetryHandler.MaxAttempts} attempts. See inner exception for details.", mostRecentlyCaughtException); } } From 4f32bda3f1785c29d1ec63e55492c45a0bbd60a5 Mon Sep 17 00:00:00 2001 From: Michael Stuckey Date: Fri, 13 Aug 2021 16:05:42 -0700 Subject: [PATCH 3/3] Fix tests --- .../PublishToSymbolServerTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed.Tests/PublishToSymbolServerTest.cs b/src/Microsoft.DotNet.Build.Tasks.Feed.Tests/PublishToSymbolServerTest.cs index 9e08f09b226..cefc81c5c69 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed.Tests/PublishToSymbolServerTest.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed.Tests/PublishToSymbolServerTest.cs @@ -216,7 +216,7 @@ public async Task DownloadFileAsyncFailsForInValidUrlTest(HttpStatusCode httpSta "1234", "test.txt", path)); - Assert.Contains($"Failed to download local file '{path}' after {publishTask.RetryHandler.MaxAttempts} attempts. See inner exception for details,", actualError.Message); + Assert.Contains($"Failed to download local file '{path}' after {publishTask.RetryHandler.MaxAttempts} attempts. See inner exception for details.", actualError.Message); } [Theory] @@ -259,7 +259,7 @@ public async Task DownloadFailureWhenStatusCodeIsInvalid(HttpStatusCode httpStat "1234", "test.txt", path)); - Assert.Contains($"Failed to download local file '{path}' after {publishTask.RetryHandler.MaxAttempts} attempts. See inner exception for details,", actualError.Message); + Assert.Contains($"Failed to download local file '{path}' after {publishTask.RetryHandler.MaxAttempts} attempts. See inner exception for details.", actualError.Message); } [Theory]