Skip to content

Commit 7378d94

Browse files
Retry DownloadLibDatadog (#8014)
## Summary of changes Add retry logic with exponential backoff to the `DownloadLibDatadog` build step for Windows to handle transient network failures when vcpkg downloads dependencies from GitHub. ## Reason for change CI builds occasionally fail with 504 Gateway Timeout errors when vcpkg attempts to download tools like `7zr.exe` from GitHub during the `DownloadLibDatadog` step. These transient failures cause unnecessary build failures. Example error from CI: ` error: https://github.com/ip7z/7zip/releases/download/25.01/7zr.exe: failed: status code 504` ## Implementation details - Wrap the vcpkg install command in a retry loop (max 3 attempts) - Apply exponential backoff between retries: 5s, 10s, 15s - Add logging to track attempt numbers and failures - Re-throw exception if all retries are exhausted - Pattern matches existing `DownloadWafVersion` retry implementation ## Test coverage Existing CI tests will validate the change. The retry mechanism only activates on failures, so successful builds are unaffected. ## Other details <!-- Fixes #{issue} --> <!-- ⚠️ Note: Where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. MergeQueue is NOT enabled in this repository. If you have write access to the repo, the PR has 1-2 approvals (see above), and all of the required checks have passed, you can use the Squash and Merge button to merge the PR. If you don't have write access, or you need help, reach out in the #apm-dotnet channel in Slack. -->
1 parent 43d4334 commit 7378d94

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

tracer/build/_build/Build.Steps.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,33 @@ async Task DownloadWafVersion(string libddwafVersion = null, string uncompressFo
621621
var packages = $@"{BuildArtifactsDirectory}\obj\vcpkg\packages";
622622
var buildTrees = $@"{BuildArtifactsDirectory}\obj\vcpkg\buildtrees";
623623

624-
// This big line is the same generated by VS when installing libdatadog while building the profiler
625-
vcpkg($@"install --x-wait-for-lock --triplet ""{triplet}"" --vcpkg-root ""{vcpkgRoot}"" ""--x-manifest-root={RootDirectory}"" ""--x-install-root={installRoot}"" --downloads-root ""{downloads}"" --x-packages-root ""{packages}"" --x-buildtrees-root ""{buildTrees}"" --clean-after-build");
624+
const int maxRetries = 3;
625+
626+
for (int attempt = 1; attempt <= maxRetries; attempt++)
627+
{
628+
try
629+
{
630+
Logger.Information($"Attempt {attempt}: Running vcpkg install for {triplet}...");
631+
// This big line is the same generated by VS when installing libdatadog while building the profiler
632+
vcpkg($@"install --x-wait-for-lock --triplet ""{triplet}"" --vcpkg-root ""{vcpkgRoot}"" ""--x-manifest-root={RootDirectory}"" ""--x-install-root={installRoot}"" --downloads-root ""{downloads}"" --x-packages-root ""{packages}"" --x-buildtrees-root ""{buildTrees}"" --clean-after-build");
633+
Logger.Information($"vcpkg install succeeded on attempt {attempt}.");
634+
break; // Exit loop on success
635+
}
636+
catch (Exception ex)
637+
{
638+
Logger.Warning($"Attempt {attempt} failed: {ex.Message}");
639+
640+
if (attempt == maxRetries)
641+
{
642+
throw;
643+
}
644+
645+
// Exponential backoff before retrying
646+
var delaySeconds = 5 * attempt;
647+
Logger.Information($"Waiting {delaySeconds} seconds before retry...");
648+
await Task.Delay(TimeSpan.FromSeconds(delaySeconds));
649+
}
650+
}
626651
}
627652
}
628653
});

0 commit comments

Comments
 (0)