diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/execution_api/common/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/execution_api/common/api_bundle.cpp | 29 | ||||
-rw-r--r-- | src/buildtool/execution_api/common/api_bundle.hpp | 20 | ||||
-rw-r--r-- | src/buildtool/graph_traverser/graph_traverser.hpp | 4 | ||||
-rw-r--r-- | src/buildtool/main/main.cpp | 34 | ||||
-rw-r--r-- | src/buildtool/serve_api/serve_service/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/serve_api/serve_service/target.cpp | 19 | ||||
-rw-r--r-- | src/other_tools/just_mr/TARGETS | 2 | ||||
-rw-r--r-- | src/other_tools/just_mr/fetch.cpp | 42 | ||||
-rw-r--r-- | src/other_tools/just_mr/setup.cpp | 42 |
10 files changed, 115 insertions, 79 deletions
diff --git a/src/buildtool/execution_api/common/TARGETS b/src/buildtool/execution_api/common/TARGETS index f5164662..88eddf05 100644 --- a/src/buildtool/execution_api/common/TARGETS +++ b/src/buildtool/execution_api/common/TARGETS @@ -48,6 +48,7 @@ , ["src/buildtool/common/remote", "retry_config"] , ["src/buildtool/execution_api/local", "context"] , ["src/buildtool/execution_api/remote", "config"] + , ["src/buildtool/execution_api/remote", "context"] , ["src/buildtool/crypto", "hash_function"] ] , "private-deps": diff --git a/src/buildtool/execution_api/common/api_bundle.cpp b/src/buildtool/execution_api/common/api_bundle.cpp index edb29970..f587a91b 100644 --- a/src/buildtool/execution_api/common/api_bundle.cpp +++ b/src/buildtool/execution_api/common/api_bundle.cpp @@ -14,25 +14,26 @@ #include "src/buildtool/execution_api/common/api_bundle.hpp" -#include "src/buildtool/common/remote/retry_config.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_common.hpp" #include "src/buildtool/execution_api/local/local_api.hpp" #include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp" -ApiBundle::ApiBundle( - gsl::not_null<LocalContext const*> const& local_context, - RepositoryConfig const* repo_config, - gsl::not_null<Auth const*> const& authentication, - gsl::not_null<RetryConfig const*> const& retry_config, - gsl::not_null<RemoteExecutionConfig const*> const& remote_exec_config) - : auth{*authentication}, - retry_config{*retry_config}, - remote_config{*remote_exec_config}, +ApiBundle::ApiBundle(gsl::not_null<LocalContext const*> const& local_context, + gsl::not_null<RemoteContext const*> const& remote_context, + RepositoryConfig const* repo_config) + : auth{*remote_context->auth}, + retry_config{*remote_context->retry_config}, + remote_config{*remote_context->exec_config}, hash_function{local_context->storage_config->hash_function}, local{std::make_shared<LocalApi>(local_context, repo_config)}, - remote{CreateRemote(remote_exec_config->remote_address)} {} + remote{CreateRemote(remote_context->exec_config->remote_address, + remote_context->auth, + remote_context->retry_config)} {} -auto ApiBundle::CreateRemote(std::optional<ServerAddress> const& address) const +auto ApiBundle::CreateRemote( + std::optional<ServerAddress> const& address, + gsl::not_null<Auth const*> const& authentication, + gsl::not_null<RetryConfig const*> const& retry_config) const -> gsl::not_null<IExecutionApi::Ptr> { if (address) { ExecutionConfiguration config; @@ -40,8 +41,8 @@ auto ApiBundle::CreateRemote(std::optional<ServerAddress> const& address) const return std::make_shared<BazelApi>("remote-execution", address->host, address->port, - &auth, - &retry_config, + authentication, + retry_config, config, hash_function); } diff --git a/src/buildtool/execution_api/common/api_bundle.hpp b/src/buildtool/execution_api/common/api_bundle.hpp index d6cf4423..7d524b2e 100644 --- a/src/buildtool/execution_api/common/api_bundle.hpp +++ b/src/buildtool/execution_api/common/api_bundle.hpp @@ -27,6 +27,7 @@ #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/execution_api/local/context.hpp" #include "src/buildtool/execution_api/remote/config.hpp" +#include "src/buildtool/execution_api/remote/context.hpp" /// \brief Utility structure for instantiation of local and remote apis at the /// same time. If the remote api cannot be instantiated, it falls back to @@ -34,13 +35,20 @@ struct ApiBundle final { explicit ApiBundle( gsl::not_null<LocalContext const*> const& local_context, - RepositoryConfig const* repo_config, - gsl::not_null<Auth const*> const& authentication, - gsl::not_null<RetryConfig const*> const& retry_config, - gsl::not_null<RemoteExecutionConfig const*> const& remote_exec_config); + gsl::not_null<RemoteContext const*> const& remote_context, + RepositoryConfig const* repo_config); - [[nodiscard]] auto CreateRemote(std::optional<ServerAddress> const& address) - const -> gsl::not_null<IExecutionApi::Ptr>; + /// \brief Create a Remote object based on the given arguments. + /// \param address The endpoint address. + /// \param authentication The remote authentication configuration. + /// \param retry_config The retry strategy configuration. + /// \returns A configured api: BazelApi if a remote address is given, + /// otherwise fall back to the already configured LocalApi instance. + [[nodiscard]] auto CreateRemote( + std::optional<ServerAddress> const& address, + gsl::not_null<Auth const*> const& authentication, + gsl::not_null<RetryConfig const*> const& retry_config) const + -> gsl::not_null<IExecutionApi::Ptr>; // Needed to be set before creating the remote (via CreateRemote) Auth const& auth; diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp index b10427cd..fce9b7d4 100644 --- a/src/buildtool/graph_traverser/graph_traverser.hpp +++ b/src/buildtool/graph_traverser/graph_traverser.hpp @@ -391,7 +391,9 @@ class GraphTraverser { DependencyGraph const& g, std::vector<ArtifactIdentifier> const& artifact_ids) const -> bool { // setup rebuilder with api for cache endpoint - auto api_cached = apis_.CreateRemote(apis_.remote_config.cache_address); + auto api_cached = apis_.CreateRemote(apis_.remote_config.cache_address, + &apis_.auth, + &apis_.retry_config); Rebuilder executor{repo_config_, &*apis_.local, &*apis_.remote, diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 1676cbb4..10fde879 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -75,6 +75,7 @@ #include "src/buildtool/execution_api/local/config.hpp" #include "src/buildtool/execution_api/local/context.hpp" #include "src/buildtool/execution_api/remote/config.hpp" +#include "src/buildtool/execution_api/remote/context.hpp" #include "src/buildtool/graph_traverser/graph_traverser.hpp" #include "src/buildtool/main/describe.hpp" #include "src/buildtool/main/retry.hpp" @@ -815,12 +816,15 @@ auto main(int argc, char* argv[]) -> int { .exec_config = &*local_exec_config, .storage_config = &*storage_config, .storage = &storage}; + // pack the remote context instances to be passed as needed + RemoteContext const remote_context{ + .auth = &*auth_config, + .retry_config = &retry_config, + .exec_config = &remote_exec_config}; ApiBundle const exec_apis{&local_context, - /*repo_config=*/nullptr, - &*auth_config, - &retry_config, - &remote_exec_config}; + &remote_context, + /*repo_config=*/nullptr}; return execution_server->Run(&local_context, exec_apis, @@ -877,12 +881,15 @@ auto main(int argc, char* argv[]) -> int { .exec_config = &*local_exec_config, .storage_config = &*storage_config, .storage = &storage}; + // pack the remote context instances to be passed as needed + RemoteContext const remote_context{ + .auth = &*auth_config, + .retry_config = &*retry_config, + .exec_config = &*remote_exec_config}; ApiBundle const serve_apis{&local_context, - /*repo_config=*/nullptr, - &*auth_config, - &*retry_config, - &*remote_exec_config}; + &remote_context, + /*repo_config=*/nullptr}; auto serve = ServeApi::Create(*serve_config, &storage, &serve_apis); @@ -972,12 +979,13 @@ auto main(int argc, char* argv[]) -> int { LocalContext const local_context{.exec_config = &*local_exec_config, .storage_config = &*storage_config, .storage = &storage}; + // pack the remote context instances to be passed as needed + RemoteContext const remote_context{.auth = &*auth_config, + .retry_config = &*retry_config, + .exec_config = &*remote_exec_config}; - ApiBundle const main_apis{&local_context, - &repo_config, - &*auth_config, - &*retry_config, - &*remote_exec_config}; + ApiBundle const main_apis{ + &local_context, &remote_context, &repo_config}; GraphTraverser const traverser{ {jobs, std::move(arguments.build), diff --git a/src/buildtool/serve_api/serve_service/TARGETS b/src/buildtool/serve_api/serve_service/TARGETS index 4374dafd..44ee4427 100644 --- a/src/buildtool/serve_api/serve_service/TARGETS +++ b/src/buildtool/serve_api/serve_service/TARGETS @@ -106,6 +106,7 @@ , ["src/buildtool/build_engine/target_map", "result_map"] , ["src/buildtool/common/remote", "remote_common"] , ["src/buildtool/common/remote", "retry_config"] + , ["src/buildtool/execution_api/remote", "context"] , ["src/buildtool/file_system", "file_system_manager"] , ["src/buildtool/graph_traverser", "graph_traverser"] , ["src/buildtool/logging", "log_level"] diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp index 001b9387..16cc37a4 100644 --- a/src/buildtool/serve_api/serve_service/target.cpp +++ b/src/buildtool/serve_api/serve_service/target.cpp @@ -28,6 +28,7 @@ #include "src/buildtool/common/remote/retry_config.hpp" #include "src/buildtool/common/repository_config.hpp" #include "src/buildtool/common/statistics.hpp" +#include "src/buildtool/execution_api/remote/context.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/file_system/object_type.hpp" #include "src/buildtool/graph_traverser/graph_traverser.hpp" @@ -493,13 +494,17 @@ auto TargetService::ServeTarget( traverser_args.stage = std::nullopt; traverser_args.rebuild = std::nullopt; - // Use a new ApiBundle that knows about local repository config for - // traversing. - ApiBundle const local_apis{&local_context_, - &repository_config, - &apis_.auth, - &apis_.retry_config, - &(*remote_config)}; + // pack the remote context instances to be passed as needed + RemoteContext const dispatch_context{ + .auth = &apis_.auth, + .retry_config = &apis_.retry_config, + .exec_config = &(*remote_config)}; + + // Use a new ApiBundle that knows about local repository config and + // dispatch endpoint for traversing + ApiBundle const local_apis{ + &local_context_, &dispatch_context, &repository_config}; + GraphTraverser const traverser{ std::move(traverser_args), &repository_config, diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS index 619a664c..15478898 100644 --- a/src/other_tools/just_mr/TARGETS +++ b/src/other_tools/just_mr/TARGETS @@ -139,6 +139,7 @@ , ["src/buildtool/execution_api/local", "config"] , ["src/buildtool/execution_api/local", "context"] , ["src/buildtool/execution_api/remote", "config"] + , ["src/buildtool/execution_api/remote", "context"] , ["src/buildtool/serve_api/remote", "config"] , ["src/buildtool/serve_api/remote", "serve_api"] ] @@ -211,6 +212,7 @@ , ["src/buildtool/execution_api/local", "config"] , ["src/buildtool/execution_api/local", "context"] , ["src/buildtool/execution_api/remote", "config"] + , ["src/buildtool/execution_api/remote", "context"] , ["src/buildtool/serve_api/remote", "config"] , ["src/buildtool/serve_api/remote", "serve_api"] ] diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index e7d1f775..8da3647b 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -27,6 +27,7 @@ #include "src/buildtool/execution_api/local/config.hpp" #include "src/buildtool/execution_api/local/context.hpp" #include "src/buildtool/execution_api/remote/config.hpp" +#include "src/buildtool/execution_api/remote/context.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/main/retry.hpp" @@ -402,43 +403,46 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, Logger::Log(LogLevel::Info, "Found {} to fetch", fetchables); } - // setup remote execution config - auto remote_exec_config = JustMR::Utils::CreateRemoteExecutionConfig( - common_args.remote_execution_address, common_args.remote_serve_address); - if (not remote_exec_config) { + // setup local execution config + auto local_exec_config = + JustMR::Utils::CreateLocalExecutionConfig(common_args); + if (not local_exec_config) { return kExitConfigError; } + // pack the local context instances to be passed to ApiBundle + LocalContext const local_context{.exec_config = &*local_exec_config, + .storage_config = &storage_config, + .storage = &storage}; + // setup authentication config auto auth_config = JustMR::Utils::CreateAuthConfig(auth_args); if (not auth_config) { return kExitConfigError; } - // setup local execution config - auto local_exec_config = - JustMR::Utils::CreateLocalExecutionConfig(common_args); - if (not local_exec_config) { - return kExitConfigError; - } - // setup the retry config auto retry_config = CreateRetryConfig(retry_args); if (not retry_config) { return kExitConfigError; } - // pack the local context instances to be passed to ApiBundle - LocalContext const local_context{.exec_config = &*local_exec_config, - .storage_config = &storage_config, - .storage = &storage}; + // setup remote execution config + auto remote_exec_config = JustMR::Utils::CreateRemoteExecutionConfig( + common_args.remote_execution_address, common_args.remote_serve_address); + if (not remote_exec_config) { + return kExitConfigError; + } + + // pack the remote context instances to be passed to ApiBundle + RemoteContext const remote_context{.auth = &*auth_config, + .retry_config = &*retry_config, + .exec_config = &*remote_exec_config}; // setup the APIs for archive fetches; only happens if in native mode ApiBundle const apis{&local_context, - /*repo_config=*/nullptr, - &*auth_config, - &*retry_config, - &*remote_exec_config}; + &remote_context, + /*repo_config=*/nullptr}; bool const has_remote_api = apis.local != apis.remote and not common_args.compatible; diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp index 40607b00..88bd0ca5 100644 --- a/src/other_tools/just_mr/setup.cpp +++ b/src/other_tools/just_mr/setup.cpp @@ -29,6 +29,7 @@ #include "src/buildtool/execution_api/local/config.hpp" #include "src/buildtool/execution_api/local/context.hpp" #include "src/buildtool/execution_api/remote/config.hpp" +#include "src/buildtool/execution_api/remote/context.hpp" #include "src/buildtool/file_system/symlinks_map/resolve_symlinks_map.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" @@ -124,42 +125,45 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config, "Found {} repositories to set up", setup_repos->to_setup.size()); - // setup remote execution config - auto remote_exec_config = JustMR::Utils::CreateRemoteExecutionConfig( - common_args.remote_execution_address, common_args.remote_serve_address); - if (not remote_exec_config) { + // setup local execution config + auto local_exec_config = + JustMR::Utils::CreateLocalExecutionConfig(common_args); + if (not local_exec_config) { return std::nullopt; } + // pack the local context instances to be passed to ApiBundle + LocalContext const local_context{.exec_config = &*local_exec_config, + .storage_config = &storage_config, + .storage = &storage}; + // setup authentication config auto auth_config = JustMR::Utils::CreateAuthConfig(auth_args); if (not auth_config) { return std::nullopt; } - // setup local execution config - auto local_exec_config = - JustMR::Utils::CreateLocalExecutionConfig(common_args); - if (not local_exec_config) { - return std::nullopt; - } - // setup the retry config auto retry_config = CreateRetryConfig(retry_args); if (not retry_config) { return std::nullopt; } - // pack the local context instances to be passed to ApiBundle - LocalContext const local_context{.exec_config = &*local_exec_config, - .storage_config = &storage_config, - .storage = &storage}; + // setup remote execution config + auto remote_exec_config = JustMR::Utils::CreateRemoteExecutionConfig( + common_args.remote_execution_address, common_args.remote_serve_address); + if (not remote_exec_config) { + return std::nullopt; + } + + // pack the remote context instances to be passed to ApiBundle + RemoteContext const remote_context{.auth = &*auth_config, + .retry_config = &*retry_config, + .exec_config = &*remote_exec_config}; ApiBundle const apis{&local_context, - /*repo_config=*/nullptr, - &*auth_config, - &*retry_config, - &*remote_exec_config}; + &remote_context, + /*repo_config=*/nullptr}; bool const has_remote_api = apis.local != apis.remote and not common_args.compatible; |