From 0d01c2bcd670f5600c337b87115e089f6d48aab5 Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Mon, 11 Dec 2023 18:26:16 +0100 Subject: Add command line options to tune the retry strategy for rpc calls Three new command line options have been added: - `--max-attempts` - `--initial-backoff-seconds` - `--max-backoff-seconds` --- src/buildtool/main/main.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/buildtool/main/main.cpp') diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index ad1447be..50b8f476 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -42,6 +42,7 @@ #include "src/buildtool/storage/target_cache.hpp" #ifndef BOOTSTRAP_BUILD_TOOL #include "src/buildtool/auth/authentication.hpp" +#include "src/buildtool/common/remote/retry_parameters.hpp" #include "src/buildtool/execution_api/execution_service/operation_cache.hpp" #include "src/buildtool/execution_api/execution_service/server_implementation.hpp" #include "src/buildtool/execution_api/remote/config.hpp" @@ -309,6 +310,29 @@ void SetupHashFunction() { : HashFunction::JustHash::Native); } +void SetupRetryConfig(RetryArguments const& args) { + if (args.max_attempts) { + if (!Retry::SetMaxAttempts(*args.max_attempts)) { + Logger::Log(LogLevel::Error, "Invalid value for max-attempts."); + std::exit(kExitFailure); + } + } + if (args.initial_backoff_seconds) { + if (!Retry::SetInitialBackoffSeconds(*args.initial_backoff_seconds)) { + Logger::Log(LogLevel::Error, + "Invalid value for initial-backoff-seconds."); + std::exit(kExitFailure); + } + } + if (args.max_backoff_seconds) { + if (!Retry::SetMaxBackoffSeconds(*args.max_backoff_seconds)) { + Logger::Log(LogLevel::Error, + "Invalid value for max-backoff-seconds."); + std::exit(kExitFailure); + } + } +} + #endif // BOOTSTRAP_BUILD_TOOL // returns path relative to `root`. @@ -881,6 +905,7 @@ auto main(int argc, char* argv[]) -> int { : std::nullopt; #ifndef BOOTSTRAP_BUILD_TOOL + SetupRetryConfig(arguments.retry); GraphTraverser const traverser{{jobs, std::move(arguments.build), std::move(stage_args), -- cgit v1.2.3