Skip to content

Commit

Permalink
[xaprepare] skip download progress for dotnet-install script (#9053)
Browse files Browse the repository at this point in the history
We are getting the error pretty early on during the build:

    Downloading dotnet-install script...
    Warning: Failed to obtain dotnet-install script size from URL 'https://dot.net/v1/dotnet-install.sh'. HTTP status code: InternalServerError (500)a
      -> https://dot.net/v1/dotnet-install.sh
        downloading dotnet-install.sh

It seems the code is timing out on the call:

    await httpClient.GetAsync (url, HttpCompletionOption.ResponseHeadersRead);

And then the code has some retry logic that eventually returns:

    return (false, 0, HttpStatusCode.InternalServerError);

I am unable to reproduce this locally on either Mac or Windows.

Reworking this code to just download the file with no progress appears
to solve the problem on Azure DevOps build agents.
  • Loading branch information
jonathanpeppers committed Jun 25, 2024
1 parent e40d395 commit b2b0f2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
2 changes: 2 additions & 0 deletions build-tools/xaprepare/xaprepare/Application/DownloadStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class DownloadStatus
const uint DefaultUpdateInterval = 1000;
readonly object updateLock = new object ();

public static readonly DownloadStatus Empty = new DownloadStatus (0, _ => { });

ConcurrentQueue<ulong> byteSnapshots;
Stopwatch watch;
Action<DownloadStatus> updater;
Expand Down
18 changes: 4 additions & 14 deletions build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,13 @@ async Task<bool> DownloadDotNetInstallScript (Context context, string dotnetScri

Log.StatusLine ("Downloading dotnet-install script...");

(bool success, ulong size, HttpStatusCode status) = await Utilities.GetDownloadSizeWithStatus (dotnetScriptUrl);
if (!success) {
if (status == HttpStatusCode.NotFound) {
Log.WarningLine ($"dotnet-install URL '{dotnetScriptUrl}' not found.");
} else {
Log.WarningLine ($"Failed to obtain dotnet-install script size from URL '{dotnetScriptUrl}'. HTTP status code: {status} ({(int) status})");
}

if (File.Exists (dotnetScriptPath)) {
Log.WarningLine ($"Using cached installation script found in '{dotnetScriptPath}'");
return true;
}
if (File.Exists (dotnetScriptPath)) {
Log.WarningLine ($"Using cached installation script found in '{dotnetScriptPath}'");
return true;
}

DownloadStatus downloadStatus = Utilities.SetupDownloadStatus (context, size, context.InteractiveSession);
Log.StatusLine ($" {context.Characters.Link} {dotnetScriptUrl}", ConsoleColor.White);
await Download (context, dotnetScriptUrl, tempDotnetScriptPath, "dotnet-install", Path.GetFileName (dotnetScriptUrl.LocalPath), downloadStatus);
await Utilities.Download (dotnetScriptUrl, tempDotnetScriptPath, DownloadStatus.Empty);

if (File.Exists (tempDotnetScriptPath)) {
Utilities.CopyFile (tempDotnetScriptPath, dotnetScriptPath);
Expand Down

0 comments on commit b2b0f2d

Please sign in to comment.