diff options
24 files changed, 108 insertions, 112 deletions
diff --git a/src/buildtool/execution_api/common/common_api.cpp b/src/buildtool/execution_api/common/common_api.cpp index ce124a67..74e52c19 100644 --- a/src/buildtool/execution_api/common/common_api.cpp +++ b/src/buildtool/execution_api/common/common_api.cpp @@ -82,9 +82,8 @@ auto CommonRetrieveToFds( } /// NOLINTNEXTLINE(misc-no-recursion) -auto CommonUploadBlobTree( - BlobTreePtr const& blob_tree, - gsl::not_null<const IExecutionApi*> const& api) noexcept -> bool { +auto CommonUploadBlobTree(BlobTreePtr const& blob_tree, + IExecutionApi const& api) noexcept -> bool { // Create digest list from blobs for batch availability check. auto missing_blobs_info = GetMissingArtifactsInfo<BlobTreePtr>( api, blob_tree->begin(), blob_tree->end(), [](BlobTreePtr const& node) { @@ -115,19 +114,19 @@ auto CommonUploadBlobTree( std::move(node->Blob()), /*exception_is_fatal=*/false, [&api](ArtifactBlobContainer&& blobs) -> bool { - return api->Upload(std::move(blobs), - /*skip_find_missing=*/true); + return api.Upload(std::move(blobs), + /*skip_find_missing=*/true); })) { return false; } } } // Transfer any remaining blobs. - return api->Upload(std::move(container), /*skip_find_missing=*/true); + return api.Upload(std::move(container), /*skip_find_missing=*/true); } auto CommonUploadTreeCompatible( - gsl::not_null<const IExecutionApi*> const& api, + IExecutionApi const& api, DirectoryTreePtr const& build_root, BazelMsgFactory::LinkDigestResolveFunc const& resolve_links) noexcept -> std::optional<ArtifactDigest> { @@ -141,8 +140,8 @@ auto CommonUploadTreeCompatible( ArtifactDigest{blob.digest}, blob.data, blob.is_exec}), /*exception_is_fatal=*/false, [&api](ArtifactBlobContainer&& container) -> bool { - return api->Upload(std::move(container), - /*skip_find_missing=*/false); + return api.Upload(std::move(container), + /*skip_find_missing=*/false); }); }); if (not digest) { @@ -156,14 +155,14 @@ auto CommonUploadTreeCompatible( return oss.str(); }); // Upload remaining blobs. - if (not api->Upload(std::move(blobs), /*skip_find_missing=*/false)) { + if (not api.Upload(std::move(blobs), /*skip_find_missing=*/false)) { Logger::Log(LogLevel::Debug, "failed to upload blobs for build root."); return std::nullopt; } return ArtifactDigest{*digest}; } -auto CommonUploadTreeNative(gsl::not_null<const IExecutionApi*> const& api, +auto CommonUploadTreeNative(IExecutionApi const& api, DirectoryTreePtr const& build_root) noexcept -> std::optional<ArtifactDigest> { auto blob_tree = BlobTree::FromDirectoryTree(build_root); @@ -175,14 +174,14 @@ auto CommonUploadTreeNative(gsl::not_null<const IExecutionApi*> const& api, auto tree_blob = (*blob_tree)->Blob(); // Upload blob tree if tree is not available at the remote side (content // first). - if (not api->IsAvailable(tree_blob.digest)) { + if (not api.IsAvailable(tree_blob.digest)) { if (not CommonUploadBlobTree(*blob_tree, api)) { Logger::Log(LogLevel::Debug, "failed to upload blob tree for build root."); return std::nullopt; } - if (not api->Upload(ArtifactBlobContainer{{tree_blob}}, - /*skip_find_missing=*/true)) { + if (not api.Upload(ArtifactBlobContainer{{tree_blob}}, + /*skip_find_missing=*/true)) { Logger::Log(LogLevel::Debug, "failed to upload tree blob for build root."); return std::nullopt; diff --git a/src/buildtool/execution_api/common/common_api.hpp b/src/buildtool/execution_api/common/common_api.hpp index e35be206..c11180da 100644 --- a/src/buildtool/execution_api/common/common_api.hpp +++ b/src/buildtool/execution_api/common/common_api.hpp @@ -61,7 +61,7 @@ struct MissingArtifactsInfo { /// original given type, or nullopt in case of exceptions. template <typename T> [[nodiscard]] auto GetMissingArtifactsInfo( - gsl::not_null<const IExecutionApi*> const& api, + IExecutionApi const& api, typename std::vector<T>::const_iterator const& begin, typename std::vector<T>::const_iterator const& end, typename std::function<ArtifactDigest(T const&)> const& converter) noexcept @@ -78,25 +78,25 @@ template <typename T> return std::nullopt; } } - res.digests = api->IsAvailable(digests); + res.digests = api.IsAvailable(digests); return res; } /// \brief Upload missing blobs from a given BlobTree. -[[nodiscard]] auto CommonUploadBlobTree( - BlobTreePtr const& blob_tree, - gsl::not_null<const IExecutionApi*> const& api) noexcept -> bool; +[[nodiscard]] auto CommonUploadBlobTree(BlobTreePtr const& blob_tree, + IExecutionApi const& api) noexcept + -> bool; /// \brief Runs the compatible branch of local/bazel UploadTree API. [[nodiscard]] auto CommonUploadTreeCompatible( - gsl::not_null<const IExecutionApi*> const& api, + IExecutionApi const& api, DirectoryTreePtr const& build_root, BazelMsgFactory::LinkDigestResolveFunc const& resolve_links) noexcept -> std::optional<ArtifactDigest>; /// \brief Runs the native branch of local/bazel UploadTree API. [[nodiscard]] auto CommonUploadTreeNative( - gsl::not_null<const IExecutionApi*> const& api, + IExecutionApi const& api, DirectoryTreePtr const& build_root) noexcept -> std::optional<ArtifactDigest>; diff --git a/src/buildtool/execution_api/common/execution_api.hpp b/src/buildtool/execution_api/common/execution_api.hpp index 1a8ee578..5b6743e3 100644 --- a/src/buildtool/execution_api/common/execution_api.hpp +++ b/src/buildtool/execution_api/common/execution_api.hpp @@ -70,7 +70,7 @@ class IExecutionApi { [[nodiscard]] virtual auto RetrieveToPaths( std::vector<Artifact::ObjectInfo> const& artifacts_info, std::vector<std::filesystem::path> const& output_paths, - std::optional<gsl::not_null<IExecutionApi*>> const& alternative = + std::optional<gsl::not_null<const IExecutionApi*>> const& alternative = std::nullopt) const noexcept -> bool = 0; /// \brief Retrieve artifacts from CAS and write to file descriptors. @@ -88,7 +88,7 @@ class IExecutionApi { /// resolved and its containing file artifacts are recursively retrieved. [[nodiscard]] virtual auto RetrieveToCas( std::vector<Artifact::ObjectInfo> const& artifacts_info, - gsl::not_null<IExecutionApi*> const& api) const noexcept -> bool = 0; + IExecutionApi const& api) const noexcept -> bool = 0; /// \brief A variant of RetrieveToCas that is allowed to internally use /// the specified number of threads to carry out the task in parallel. @@ -98,7 +98,7 @@ class IExecutionApi { /// the remote blobs. [[nodiscard]] virtual auto ParallelRetrieveToCas( std::vector<Artifact::ObjectInfo> const& artifacts_info, - gsl::not_null<IExecutionApi*> const& api, + IExecutionApi const& api, std::size_t /* jobs */, bool /* use_blob_splitting */) const noexcept -> bool { return RetrieveToCas(artifacts_info, api); diff --git a/src/buildtool/execution_api/git/git_api.hpp b/src/buildtool/execution_api/git/git_api.hpp index 2b29fa40..53184988 100644 --- a/src/buildtool/execution_api/git/git_api.hpp +++ b/src/buildtool/execution_api/git/git_api.hpp @@ -54,8 +54,9 @@ class GitApi final : public IExecutionApi { [[nodiscard]] auto RetrieveToPaths( std::vector<Artifact::ObjectInfo> const& artifacts_info, std::vector<std::filesystem::path> const& output_paths, - std::optional<gsl::not_null<IExecutionApi*>> const& /*alternative*/ = - std::nullopt) const noexcept -> bool override { + std::optional< + gsl::not_null<const IExecutionApi*>> const& /*alternative*/ + = std::nullopt) const noexcept -> bool override { if (artifacts_info.size() != output_paths.size()) { Logger::Log(LogLevel::Error, "different number of digests and output paths."); @@ -175,10 +176,9 @@ class GitApi final : public IExecutionApi { // NOLINTNEXTLINE(misc-no-recursion) [[nodiscard]] auto RetrieveToCas( std::vector<Artifact::ObjectInfo> const& artifacts_info, - gsl::not_null<IExecutionApi*> const& api) const noexcept - -> bool override { + IExecutionApi const& api) const noexcept -> bool override { // Return immediately if target CAS is this CAS - if (this == api) { + if (this == &api) { return true; } @@ -238,14 +238,14 @@ class GitApi final : public IExecutionApi { IsExecutableObject(entry->Type())}, /*exception_is_fatal=*/true, [&api](ArtifactBlobContainer&& blobs) -> bool { - return api->Upload(std::move(blobs)); + return api.Upload(std::move(blobs)); })) { return false; } } } // Upload remaining blobs. - if (not api->Upload(std::move(tree_deps_only_blobs))) { + if (not api.Upload(std::move(tree_deps_only_blobs))) { return false; } content = tree->RawData(); @@ -270,15 +270,15 @@ class GitApi final : public IExecutionApi { IsExecutableObject(info.type)}, /*exception_is_fatal=*/true, [&api](ArtifactBlobContainer&& blobs) { - return api->Upload(std::move(blobs), - /*skip_find_missing=*/true); + return api.Upload(std::move(blobs), + /*skip_find_missing=*/true); })) { return false; } } // Upload remaining blobs to remote CAS. - return api->Upload(std::move(container), /*skip_find_missing=*/true); + return api.Upload(std::move(container), /*skip_find_missing=*/true); } [[nodiscard]] auto RetrieveToMemory( diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index fc64e842..928fb5b8 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -78,8 +78,9 @@ class LocalApi final : public IExecutionApi { [[nodiscard]] auto RetrieveToPaths( std::vector<Artifact::ObjectInfo> const& artifacts_info, std::vector<std::filesystem::path> const& output_paths, - std::optional<gsl::not_null<IExecutionApi*>> const& /*alternative*/ = - std::nullopt) const noexcept -> bool final { + std::optional< + gsl::not_null<const IExecutionApi*>> const& /*alternative*/ + = std::nullopt) const noexcept -> bool final { if (artifacts_info.size() != output_paths.size()) { Logger::Log(LogLevel::Error, "different number of digests and output paths."); @@ -171,10 +172,9 @@ class LocalApi final : public IExecutionApi { // NOLINTNEXTLINE(misc-no-recursion) [[nodiscard]] auto RetrieveToCas( std::vector<Artifact::ObjectInfo> const& artifacts_info, - gsl::not_null<IExecutionApi*> const& api) const noexcept -> bool final { - + IExecutionApi const& api) const noexcept -> bool final { // Return immediately if target CAS is this CAS - if (this == api) { + if (this == &api) { return true; } @@ -237,15 +237,15 @@ class LocalApi final : public IExecutionApi { IsExecutableObject(info.type)}, /*exception_is_fatal=*/true, [&api](ArtifactBlobContainer&& blobs) { - return api->Upload(std::move(blobs), - /*skip_find_missing=*/true); + return api.Upload(std::move(blobs), + /*skip_find_missing=*/true); })) { return false; } } // Upload remaining blobs to remote CAS. - return api->Upload(std::move(container), /*skip_find_missing=*/true); + return api.Upload(std::move(container), /*skip_find_missing=*/true); } [[nodiscard]] auto RetrieveToMemory( @@ -299,7 +299,7 @@ class LocalApi final : public IExecutionApi { if (Compatibility::IsCompatible()) { return CommonUploadTreeCompatible( - this, + *this, *build_root, [&cas = storage_->CAS()]( std::vector<bazel_re::Digest> const& digests, @@ -313,7 +313,7 @@ class LocalApi final : public IExecutionApi { }); } - return CommonUploadTreeNative(this, *build_root); + return CommonUploadTreeNative(*this, *build_root); } [[nodiscard]] auto IsAvailable(ArtifactDigest const& digest) const noexcept diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp index 04cae278..b475dfe8 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp @@ -51,7 +51,7 @@ namespace { [[nodiscard]] auto RetrieveToCas( std::vector<bazel_re::Digest> const& digests, - gsl::not_null<const IExecutionApi*> const& api, + IExecutionApi const& api, std::shared_ptr<BazelNetwork> const& network, std::unordered_map<ArtifactDigest, Artifact::ObjectInfo> const& info_map) noexcept -> bool { @@ -78,8 +78,8 @@ namespace { std::move(blob), /*exception_is_fatal=*/true, [&api](ArtifactBlobContainer&& blobs) { - return api->Upload(std::move(blobs), - /*skip_find_missing=*/true); + return api.Upload(std::move(blobs), + /*skip_find_missing=*/true); })) { return false; } @@ -93,19 +93,19 @@ namespace { } // Upload remaining blobs to other CAS. - return api->Upload(std::move(container), /*skip_find_missing=*/true); + return api.Upload(std::move(container), /*skip_find_missing=*/true); } [[nodiscard]] auto RetrieveToCasSplitted( Artifact::ObjectInfo const& artifact_info, - gsl::not_null<const IExecutionApi*> const& this_api, - gsl::not_null<const IExecutionApi*> const& other_api, + IExecutionApi const& this_api, + IExecutionApi const& other_api, std::shared_ptr<BazelNetwork> const& network, std::unordered_map<ArtifactDigest, Artifact::ObjectInfo> const& info_map) noexcept -> bool { // Split blob into chunks at the remote side and retrieve chunk digests. - auto chunk_digests = this_api->SplitBlob(artifact_info.digest); + auto chunk_digests = this_api.SplitBlob(artifact_info.digest); if (not chunk_digests) { // If blob splitting failed, fall back to regular fetching. return ::RetrieveToCas( @@ -118,7 +118,7 @@ namespace { auto unique_digests = std::vector<ArtifactDigest>{digest_set.begin(), digest_set.end()}; - auto missing_artifact_digests = other_api->IsAvailable(unique_digests); + auto missing_artifact_digests = other_api.IsAvailable(unique_digests); auto missing_digests = std::vector<bazel_re::Digest>{}; missing_digests.reserve(digest_set.size()); @@ -133,7 +133,7 @@ namespace { } // Assemble blob from chunks. - auto digest = other_api->SpliceBlob(artifact_info.digest, *chunk_digests); + auto digest = other_api.SpliceBlob(artifact_info.digest, *chunk_digests); if (not digest) { // If blob splicing failed, fall back to regular fetching. return ::RetrieveToCas( @@ -221,7 +221,7 @@ auto BazelApi::CreateAction( [[nodiscard]] auto BazelApi::RetrieveToPaths( std::vector<Artifact::ObjectInfo> const& artifacts_info, std::vector<std::filesystem::path> const& output_paths, - std::optional<gsl::not_null<IExecutionApi*>> const& alternative) + std::optional<gsl::not_null<const IExecutionApi*>> const& alternative) const noexcept -> bool { if (artifacts_info.size() != output_paths.size()) { Logger::Log(LogLevel::Warning, @@ -315,10 +315,9 @@ auto BazelApi::CreateAction( // NOLINTNEXTLINE(misc-no-recursion) [[nodiscard]] auto BazelApi::RetrieveToCas( std::vector<Artifact::ObjectInfo> const& artifacts_info, - gsl::not_null<IExecutionApi*> const& api) const noexcept -> bool { - + IExecutionApi const& api) const noexcept -> bool { // Return immediately if target CAS is this CAS - if (this == api) { + if (this == &api) { return true; } @@ -361,12 +360,11 @@ auto BazelApi::CreateAction( /// NOLINTNEXTLINE(misc-no-recursion) [[nodiscard]] auto BazelApi::ParallelRetrieveToCas( std::vector<Artifact::ObjectInfo> const& artifacts_info, - gsl::not_null<IExecutionApi*> const& api, + IExecutionApi const& api, std::size_t jobs, bool use_blob_splitting) const noexcept -> bool { - // Return immediately if target CAS is this CAS - if (this == api) { + if (this == &api) { return true; } @@ -410,9 +408,9 @@ auto BazelApi::CreateAction( &info_map = missing_artifacts_info->back_map, use_blob_splitting]() { if (use_blob_splitting and network_->BlobSplitSupport() and - api->BlobSpliceSupport() + api.BlobSpliceSupport() ? ::RetrieveToCasSplitted( - info, this, api, network_, info_map) + info, *this, api, network_, info_map) : ::RetrieveToCas( {info.digest}, api, network_, info_map)) { return; @@ -461,7 +459,7 @@ auto BazelApi::CreateAction( if (Compatibility::IsCompatible()) { return CommonUploadTreeCompatible( - this, + *this, *build_root, [&network = network_](std::vector<bazel_re::Digest> const& digests, std::vector<std::string>* targets) { @@ -475,7 +473,7 @@ auto BazelApi::CreateAction( }); } - return CommonUploadTreeNative(this, *build_root); + return CommonUploadTreeNative(*this, *build_root); } [[nodiscard]] auto BazelApi::IsAvailable( diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp index 62080bf1..a9149450 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp @@ -62,7 +62,7 @@ class BazelApi final : public IExecutionApi { [[nodiscard]] auto RetrieveToPaths( std::vector<Artifact::ObjectInfo> const& artifacts_info, std::vector<std::filesystem::path> const& output_paths, - std::optional<gsl::not_null<IExecutionApi*>> const& alternative = + std::optional<gsl::not_null<const IExecutionApi*>> const& alternative = std::nullopt) const noexcept -> bool final; [[nodiscard]] auto RetrieveToFds( @@ -72,13 +72,13 @@ class BazelApi final : public IExecutionApi { [[nodiscard]] auto ParallelRetrieveToCas( std::vector<Artifact::ObjectInfo> const& artifacts_info, - gsl::not_null<IExecutionApi*> const& api, + IExecutionApi const& api, std::size_t jobs, bool use_blob_splitting) const noexcept -> bool final; [[nodiscard]] auto RetrieveToCas( std::vector<Artifact::ObjectInfo> const& artifacts_info, - gsl::not_null<IExecutionApi*> const& api) const noexcept -> bool final; + IExecutionApi const& api) const noexcept -> bool final; [[nodiscard]] auto Upload(ArtifactBlobContainer&& blobs, bool skip_find_missing) const noexcept diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index d84f4e7e..e02dc454 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -113,7 +113,7 @@ class ExecutorImpl { if (not api->ParallelRetrieveToCas( std::vector<Artifact::ObjectInfo>{Artifact::ObjectInfo{ *root_digest, ObjectType::Tree, /* failed= */ false}}, - &(*alternative_api), + *alternative_api, /* jobs= */ 1, /* use_blob_splitting= */ true)) { Logger::Log(LogLevel::Error, @@ -149,7 +149,7 @@ class ExecutorImpl { for (auto const& [path, info] : artifacts) { object_infos.emplace_back(info); } - if (not alternative_api->RetrieveToCas(object_infos, api)) { + if (not alternative_api->RetrieveToCas(object_infos, *api)) { Logger::Log(LogLevel::Warning, "Failed to retrieve back artifacts from " "dispatch endpoint"); @@ -197,7 +197,7 @@ class ExecutorImpl { // Check if requested artifact is available in local CAS and // upload to remote CAS in case it is. if (local_api->IsAvailable(object_info_opt->digest) and - local_api->RetrieveToCas({*object_info_opt}, remote_api)) { + local_api->RetrieveToCas({*object_info_opt}, *remote_api)) { return true; } diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp index 8211c476..a1b394bd 100644 --- a/src/buildtool/graph_traverser/graph_traverser.hpp +++ b/src/buildtool/graph_traverser/graph_traverser.hpp @@ -157,7 +157,7 @@ class GraphTraverser { if (clargs_.stage->remember) { if (not apis_.remote->ParallelRetrieveToCas( - *object_infos, &*apis_.local, clargs_.jobs, true)) { + *object_infos, *apis_.local, clargs_.jobs, true)) { Logger::Log(logger_, LogLevel::Warning, "Failed to copy objects to CAS"); diff --git a/src/buildtool/main/add_to_cas.cpp b/src/buildtool/main/add_to_cas.cpp index 984c2007..b7d79997 100644 --- a/src/buildtool/main/add_to_cas.cpp +++ b/src/buildtool/main/add_to_cas.cpp @@ -107,7 +107,7 @@ auto AddArtifactsToCas(ToAddArguments const& clargs, ApiBundle const& apis) auto object = std::vector<Artifact::ObjectInfo>{ Artifact::ObjectInfo{ArtifactDigest(*digest), *object_type, false}}; - if (not apis.local->RetrieveToCas(object, &*apis.remote)) { + if (not apis.local->RetrieveToCas(object, *apis.remote)) { Logger::Log(LogLevel::Error, "Failed to upload artifact to remote endpoint"); return false; diff --git a/src/buildtool/main/build_utils.cpp b/src/buildtool/main/build_utils.cpp index 2f7549b7..ab03ec08 100644 --- a/src/buildtool/main/build_utils.cpp +++ b/src/buildtool/main/build_utils.cpp @@ -112,7 +112,7 @@ auto CreateTargetCacheWriterMap( auto downloader = [apis, &jobs, strategy](auto infos) { return apis->remote->ParallelRetrieveToCas( infos, - &*apis->local, + *apis->local, jobs, strategy == TargetCacheWriteStrategy::Split); }; diff --git a/src/buildtool/main/describe.cpp b/src/buildtool/main/describe.cpp index 7387cdbf..4739ba88 100644 --- a/src/buildtool/main/describe.cpp +++ b/src/buildtool/main/describe.cpp @@ -314,7 +314,7 @@ auto DescribeTarget(BuildMaps::Target::ConfiguredTarget const& id, auto const& desc_info = Artifact::ObjectInfo{.digest = *dgst, .type = ObjectType::File}; if (!apis.local->IsAvailable(*dgst)) { - if (!apis.remote->RetrieveToCas({desc_info}, &*apis.local)) { + if (!apis.remote->RetrieveToCas({desc_info}, *apis.local)) { Logger::Log(LogLevel::Error, "Failed to retrieve blob {} from remote CAS", desc_info.ToString()); diff --git a/src/buildtool/main/install_cas.cpp b/src/buildtool/main/install_cas.cpp index 5c213925..3c06a91c 100644 --- a/src/buildtool/main/install_cas.cpp +++ b/src/buildtool/main/install_cas.cpp @@ -77,7 +77,7 @@ auto FetchAndInstallArtifacts(ApiBundle const& apis, if (clargs.remember) { if (not apis.remote->ParallelRetrieveToCas( - {object_info}, &*apis.local, 1, true)) { + {object_info}, *apis.local, 1, true)) { Logger::Log(LogLevel::Warning, "Failed to copy artifact {} to local CAS", object_info.ToString()); diff --git a/src/buildtool/serve_api/remote/target_client.cpp b/src/buildtool/serve_api/remote/target_client.cpp index c8a7fc94..7b13b90e 100644 --- a/src/buildtool/serve_api/remote/target_client.cpp +++ b/src/buildtool/serve_api/remote/target_client.cpp @@ -38,7 +38,7 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key, const std::string& repo_key) const noexcept -> std::optional<serve_target_result_t> { // make sure the blob containing the key is in the remote cas - if (!apis_.local->RetrieveToCas({key.Id()}, &*apis_.remote)) { + if (!apis_.local->RetrieveToCas({key.Id()}, *apis_.remote)) { return serve_target_result_t{ std::in_place_index<1>, fmt::format("Failed to retrieve to remote cas ObjectInfo {}", @@ -48,7 +48,7 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key, if (!apis_.local->RetrieveToCas( {Artifact::ObjectInfo{.digest = ArtifactDigest{repo_key, 0, false}, .type = ObjectType::File}}, - &*apis_.remote)) { + *apis_.remote)) { return serve_target_result_t{ std::in_place_index<1>, fmt::format("Failed to retrieve to remote cas blob {}", repo_key)}; @@ -94,7 +94,7 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key, } auto const& dispatch_info = Artifact::ObjectInfo{ .digest = ArtifactDigest{*dispatch_dgst}, .type = ObjectType::File}; - if (!apis_.local->RetrieveToCas({dispatch_info}, &*apis_.remote)) { + if (!apis_.local->RetrieveToCas({dispatch_info}, *apis_.remote)) { return serve_target_result_t{ std::in_place_index<1>, fmt::format("Failed to upload blob {} to remote cas", @@ -127,7 +127,7 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key, auto const& obj_info = Artifact::ObjectInfo{ .digest = target_value_dgst, .type = ObjectType::File}; if (!apis_.local->IsAvailable(target_value_dgst)) { - if (!apis_.remote->RetrieveToCas({obj_info}, &*apis_.local)) { + if (!apis_.remote->RetrieveToCas({obj_info}, *apis_.local)) { return serve_target_result_t{ std::in_place_index<1>, fmt::format( diff --git a/src/buildtool/serve_api/serve_service/source_tree.cpp b/src/buildtool/serve_api/serve_service/source_tree.cpp index 634ce795..2fb5acfb 100644 --- a/src/buildtool/serve_api/serve_service/source_tree.cpp +++ b/src/buildtool/serve_api/serve_service/source_tree.cpp @@ -227,7 +227,7 @@ auto SourceTreeService::ServeCommitTree( if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit(LogLevel::Error, "Failed to sync tree {} from local Git cache", tree_id); @@ -283,7 +283,7 @@ auto SourceTreeService::ServeCommitTree( if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit( LogLevel::Error, "Failed to sync tree {} from known repository {}", @@ -346,7 +346,7 @@ auto SourceTreeService::SyncArchive(std::string const& tree_id, if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit(LogLevel::Error, "Failed to sync tree {} from repository {}", tree_id, @@ -832,7 +832,7 @@ auto SourceTreeService::ServeArchiveTree( apis_.remote->RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::File}}, - &(*apis_.local)))) { + *apis_.local))) { // content could not be found response->set_status(ServeArchiveTreeResponse::NOT_FOUND); return ::grpc::Status::OK; @@ -964,7 +964,7 @@ auto SourceTreeService::DistdirImportToGit( if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit(LogLevel::Error, "Failed to sync tree {} from local CAS", tree_id); @@ -1100,7 +1100,7 @@ auto SourceTreeService::ServeDistdirTree( .type = kv.executable() ? ObjectType::Executable : ObjectType::File}}, - &(*apis_.local))) { + *apis_.local)) { logger_->Emit(LogLevel::Error, "Failed to retrieve content {} from " "remote to local CAS", @@ -1198,7 +1198,7 @@ auto SourceTreeService::ServeDistdirTree( if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit(LogLevel::Error, "Failed to sync tree {} from local CAS", tree_id); @@ -1250,7 +1250,7 @@ auto SourceTreeService::ServeDistdirTree( if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit(LogLevel::Error, "Failed to sync tree {} from local CAS", tree_id); @@ -1299,7 +1299,7 @@ auto SourceTreeService::ServeContent( if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::File}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit(LogLevel::Error, "Failed to sync content {} from local Git cache", content); @@ -1335,7 +1335,7 @@ auto SourceTreeService::ServeContent( if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::File}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit( LogLevel::Error, "Failed to sync content {} from known repository {}", @@ -1363,7 +1363,7 @@ auto SourceTreeService::ServeContent( if (not apis_.local->RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::File}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit(LogLevel::Error, "Failed to sync content {} from local CAS", content); @@ -1424,7 +1424,7 @@ auto SourceTreeService::ServeTree( if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit(LogLevel::Error, "Failed to sync tree {} from local Git cache", tree_id); @@ -1469,7 +1469,7 @@ auto SourceTreeService::ServeTree( if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit(LogLevel::Error, "Failed to sync tree {} from known repository {}", tree_id, @@ -1496,7 +1496,7 @@ auto SourceTreeService::ServeTree( if (not apis_.local->RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, - &(*apis_.remote))) { + *apis_.remote)) { logger_->Emit(LogLevel::Error, "Failed to sync tree {} from local CAS", tree_id); diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp index dda3a975..a87648dc 100644 --- a/src/buildtool/serve_api/serve_service/target.cpp +++ b/src/buildtool/serve_api/serve_service/target.cpp @@ -51,7 +51,7 @@ auto TargetService::GetDispatchList( auto const& dispatch_info = Artifact::ObjectInfo{.digest = dispatch_digest, .type = ObjectType::File}; if (not apis_.local->IsAvailable(dispatch_digest) and - not apis_.remote->RetrieveToCas({dispatch_info}, &*apis_.local)) { + not apis_.remote->RetrieveToCas({dispatch_info}, *apis_.local)) { return ::grpc::Status{::grpc::StatusCode::FAILED_PRECONDITION, fmt::format("Could not retrieve blob {} from " "remote-execution endpoint", @@ -109,7 +109,7 @@ auto TargetService::HandleFailureLog( if (not apis_.local->RetrieveToCas( {Artifact::ObjectInfo{.digest = ArtifactDigest{*digest}, .type = ObjectType::File}}, - &*apis_.remote)) { + *apis_.remote)) { auto msg = fmt::format("Failed to upload to remote CAS the failed {} log {}", failure_scope, @@ -236,7 +236,7 @@ auto TargetService::ServeTarget( return ::grpc::Status{::grpc::StatusCode::INTERNAL, msg}; } artifacts.emplace_back(target_entry->second); // add the tc value - if (not apis_.local->RetrieveToCas(artifacts, &*apis_.remote)) { + if (not apis_.local->RetrieveToCas(artifacts, *apis_.remote)) { auto msg = fmt::format( "Failed to upload to remote cas the artifacts referenced in " "the target cache entry {}", @@ -255,7 +255,7 @@ auto TargetService::ServeTarget( if (not apis_.local->IsAvailable(target_cache_key_digest) and not apis_.remote->RetrieveToCas({target_cache_key_info}, - &*apis_.local)) { + *apis_.local)) { auto msg = fmt::format( "Could not retrieve blob {} from remote-execution endpoint", target_cache_key_info.ToString()); @@ -335,7 +335,7 @@ auto TargetService::ServeTarget( not apis_.remote->RetrieveToCas( {Artifact::ObjectInfo{.digest = repo_key_dgst, .type = ObjectType::File}}, - &*apis_.local)) { + *apis_.local)) { auto msg = fmt::format( "Could not retrieve blob {} from remote-execution endpoint", repo_key->String()); @@ -566,7 +566,7 @@ auto TargetService::ServeTarget( return ::grpc::Status{::grpc::StatusCode::INTERNAL, msg}; } tc_artifacts.emplace_back(target_entry->second); // add the tc value - if (not apis_.local->RetrieveToCas(tc_artifacts, &*apis_.remote)) { + if (not apis_.local->RetrieveToCas(tc_artifacts, *apis_.remote)) { auto msg = fmt::format( "Failed to upload to remote cas the artifacts referenced in " "the target cache entry {}", @@ -910,7 +910,7 @@ auto TargetService::ServeTargetDescription( if (not apis_.local->RetrieveToCas( {Artifact::ObjectInfo{.digest = artifact_dgst, .type = ObjectType::File}}, - &*apis_.remote)) { + *apis_.remote)) { auto error_msg = fmt::format( "Failed to upload to remote cas the description blob {}", artifact_dgst.hash()); diff --git a/src/other_tools/ops_maps/archive_fetch_map.cpp b/src/other_tools/ops_maps/archive_fetch_map.cpp index 1e89025d..bf655dfd 100644 --- a/src/other_tools/ops_maps/archive_fetch_map.cpp +++ b/src/other_tools/ops_maps/archive_fetch_map.cpp @@ -40,7 +40,7 @@ void ProcessContent( {Artifact::ObjectInfo{ .digest = ArtifactDigest{content, 0, /*is_tree=*/false}, .type = ObjectType::File}}, - *remote_api)) { + **remote_api)) { // give a warning (*logger)(fmt::format("Failed to back up content {} from local CAS " "to remote", diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp index 97e959d4..190c9611 100644 --- a/src/other_tools/ops_maps/content_cas_map.cpp +++ b/src/other_tools/ops_maps/content_cas_map.cpp @@ -221,7 +221,7 @@ auto CreateContentCASMap( if (remote_api.value()->RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::File}}, - local_api)) { + *local_api)) { JustMRProgress::Instance().TaskTracker().Stop( key.origin); (*setter)(nullptr); @@ -233,7 +233,7 @@ auto CreateContentCASMap( remote_api.value()->RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::File}}, - local_api)) { + *local_api)) { JustMRProgress::Instance().TaskTracker().Stop(key.origin); (*setter)(nullptr); return; diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp index 0a0c7eb9..844aad31 100644 --- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp +++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp @@ -45,7 +45,7 @@ void BackupToRemote(std::string const& tree_id, {Artifact::ObjectInfo{ .digest = ArtifactDigest{tree_id, 0, /*is_tree=*/true}, .type = ObjectType::Tree}}, - remote_api)) { + *remote_api)) { // give a warning (*logger)(fmt::format( "Failed to back up tree {} from local CAS to remote", @@ -243,7 +243,7 @@ auto CreateGitTreeFetchMap( remote_api.value()->RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, - local_api)) { + *local_api)) { JustMRProgress::Instance().TaskTracker().Stop(key.origin); MoveCASTreeToGit( key.hash, diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp index 78a116ae..0045e354 100644 --- a/src/other_tools/root_maps/commit_git_map.cpp +++ b/src/other_tools/root_maps/commit_git_map.cpp @@ -723,7 +723,7 @@ void EnsureCommit( {Artifact::ObjectInfo{ .digest = root_digest, .type = ObjectType::Tree}}, - local_api)) { + *local_api)) { JustMRProgress::Instance().TaskTracker().Stop( repo_info.origin); // Move tree from local CAS to local Git storage diff --git a/src/other_tools/root_maps/distdir_git_map.cpp b/src/other_tools/root_maps/distdir_git_map.cpp index afd83ba6..7d4c7da8 100644 --- a/src/other_tools/root_maps/distdir_git_map.cpp +++ b/src/other_tools/root_maps/distdir_git_map.cpp @@ -425,7 +425,7 @@ auto CreateDistdirGitMap( {Artifact::ObjectInfo{ .digest = digest, .type = ObjectType::Tree}}, - *remote_api)) { + **remote_api)) { (*logger)(fmt::format("Failed to sync tree {} from " "local CAS with remote CAS.", tree_id), diff --git a/src/other_tools/root_maps/root_utils.cpp b/src/other_tools/root_maps/root_utils.cpp index 38c1e205..7df58f37 100644 --- a/src/other_tools/root_maps/root_utils.cpp +++ b/src/other_tools/root_maps/root_utils.cpp @@ -56,7 +56,7 @@ auto EnsureAbsentRootOnServe( {Artifact::ObjectInfo{ .digest = ArtifactDigest{tree_id, 0, /*is_tree=*/true}, .type = ObjectType::Tree}}, - *remote_api)) { + **remote_api)) { (*logger)(fmt::format("Failed to sync tree {} from repository {}", tree_id, repo_path.string()), diff --git a/src/other_tools/root_maps/tree_id_git_map.cpp b/src/other_tools/root_maps/tree_id_git_map.cpp index bf6d0913..503b3c30 100644 --- a/src/other_tools/root_maps/tree_id_git_map.cpp +++ b/src/other_tools/root_maps/tree_id_git_map.cpp @@ -40,7 +40,7 @@ void UploadToServeAndSetRoot(ServeApi const& serve, if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, .type = ObjectType::Tree}}, - remote_api)) { + *remote_api)) { (*logger)(fmt::format("Failed to sync tree {} from local Git cache " "to remote CAS", tree_id), diff --git a/test/buildtool/execution_engine/executor/executor.test.cpp b/test/buildtool/execution_engine/executor/executor.test.cpp index 9b1c8263..26fd9b7d 100644 --- a/test/buildtool/execution_engine/executor/executor.test.cpp +++ b/test/buildtool/execution_engine/executor/executor.test.cpp @@ -149,7 +149,7 @@ class TestApi : public IExecutionApi { [[nodiscard]] auto RetrieveToPaths( std::vector<Artifact::ObjectInfo> const& /*unused*/, std::vector<std::filesystem::path> const& /*unused*/, - std::optional<gsl::not_null<IExecutionApi*>> const& /* unused */) + std::optional<gsl::not_null<const IExecutionApi*>> const& /* unused */) const noexcept -> bool final { return false; // not needed by Executor } @@ -161,8 +161,7 @@ class TestApi : public IExecutionApi { } [[nodiscard]] auto RetrieveToCas( std::vector<Artifact::ObjectInfo> const& unused, - gsl::not_null<IExecutionApi*> const& /*unused*/) const noexcept - -> bool final { + IExecutionApi const& /*unused*/) const noexcept -> bool final { // Note that a false-positive "free-nonheap-object" warning is thrown by // gcc 12.2 with GNU libstdc++, if the caller passes a temporary vector // that is not used by this function. Therefore, we explicitly use this |