summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/root_maps/TARGETS17
-rw-r--r--src/other_tools/root_maps/root_utils.cpp84
-rw-r--r--src/other_tools/root_maps/root_utils.hpp41
3 files changed, 2 insertions, 140 deletions
diff --git a/src/other_tools/root_maps/TARGETS b/src/other_tools/root_maps/TARGETS
index 8a14bf58..5d530b2a 100644
--- a/src/other_tools/root_maps/TARGETS
+++ b/src/other_tools/root_maps/TARGETS
@@ -228,23 +228,10 @@
, "hdrs": ["root_utils.hpp"]
, "srcs": ["root_utils.cpp"]
, "deps":
- [ ["@", "gsl", "", "gsl"]
- , ["src/buildtool/execution_api/common", "common"]
- , ["src/buildtool/multithreading", "async_map_consumer"]
+ [ ["src/buildtool/multithreading", "async_map_consumer"]
, ["src/buildtool/serve_api/remote", "serve_api"]
- , ["src/buildtool/storage", "config"]
]
, "stage": ["src", "other_tools", "root_maps"]
- , "private-deps":
- [ ["@", "fmt", "", "fmt"]
- , ["src/buildtool/common", "artifact_digest_factory"]
- , ["src/buildtool/common", "common"]
- , ["src/buildtool/common", "config"]
- , ["src/buildtool/crypto", "hash_function"]
- , ["src/buildtool/execution_api/serve", "mr_git_api"]
- , ["src/buildtool/execution_api/utils", "rehash_utils"]
- , ["src/buildtool/file_system", "object_type"]
- , ["src/utils/cpp", "expected"]
- ]
+ , "private-deps": [["@", "fmt", "", "fmt"]]
}
}
diff --git a/src/other_tools/root_maps/root_utils.cpp b/src/other_tools/root_maps/root_utils.cpp
index b38aa43b..00ff2408 100644
--- a/src/other_tools/root_maps/root_utils.cpp
+++ b/src/other_tools/root_maps/root_utils.cpp
@@ -16,18 +16,8 @@
#include <functional>
#include <memory>
-#include <vector>
#include "fmt/core.h"
-#include "src/buildtool/common/artifact.hpp"
-#include "src/buildtool/common/artifact_digest.hpp"
-#include "src/buildtool/common/artifact_digest_factory.hpp"
-#include "src/buildtool/common/repository_config.hpp"
-#include "src/buildtool/crypto/hash_function.hpp"
-#include "src/buildtool/execution_api/serve/mr_git_api.hpp"
-#include "src/buildtool/execution_api/utils/rehash_utils.hpp"
-#include "src/buildtool/file_system/object_type.hpp"
-#include "src/utils/cpp/expected.hpp"
auto CheckServeHasAbsentRoot(ServeApi const& serve,
std::string const& tree_id,
@@ -42,77 +32,3 @@ auto CheckServeHasAbsentRoot(ServeApi const& serve,
/*fatal=*/true);
return std::nullopt;
}
-
-auto EnsureAbsentRootOnServe(
- ServeApi const& serve,
- std::string const& tree_id,
- std::filesystem::path const& repo_path,
- gsl::not_null<StorageConfig const*> const& native_storage_config,
- StorageConfig const* compat_storage_config,
- IExecutionApi const* local_api,
- IExecutionApi const* remote_api,
- AsyncMapConsumerLoggerPtr const& logger,
- bool no_sync_is_fatal) -> bool {
- auto const native_digest = ArtifactDigestFactory::Create(
- HashFunction::Type::GitSHA1, tree_id, 0, /*is_tree=*/true);
- if (not native_digest) {
- (*logger)(fmt::format("Failed to create digest for {}", tree_id),
- /*fatal=*/true);
- return false;
- }
- // check if upload is required
- if (remote_api != nullptr) {
- // upload tree to remote CAS
- auto repo = RepositoryConfig{};
- if (not repo.SetGitCAS(repo_path)) {
- (*logger)(
- fmt::format("Failed to SetGitCAS at {}", repo_path.string()),
- /*fatal=*/true);
- return false;
- }
- auto git_api = MRGitApi{
- &repo, native_storage_config, compat_storage_config, local_api};
- if (not git_api.RetrieveToCas(
- {Artifact::ObjectInfo{.digest = *native_digest,
- .type = ObjectType::Tree}},
- *remote_api)) {
- (*logger)(fmt::format("Failed to sync tree {} from repository {}",
- tree_id,
- repo_path.string()),
- /*fatal=*/true);
- return false;
- }
- }
- // ask serve endpoint to retrieve the uploaded tree; this can only happen if
- // we have access to a digest that the remote knows
- ArtifactDigest remote_digest = *native_digest;
- if (compat_storage_config != nullptr) {
- // in compatible mode, get compatible digest from mapping, if exists
- auto cached_obj =
- RehashUtils::ReadRehashedDigest(*native_digest,
- *native_storage_config,
- *compat_storage_config,
- /*from_git=*/true);
- if (not cached_obj) {
- (*logger)(cached_obj.error(), /*fatal=*/true);
- return false;
- }
- if (not *cached_obj) {
- // digest is not known; respond based on no_sync_is_fatal flag
- (*logger)(fmt::format("No digest provided to sync root tree {}.",
- tree_id),
- /*fatal=*/no_sync_is_fatal);
- return not no_sync_is_fatal;
- }
- remote_digest = cached_obj->value().digest;
- }
- if (not serve.GetTreeFromRemote(remote_digest)) {
- // respond based on no_sync_is_fatal flag
- (*logger)(
- fmt::format("Serve endpoint failed to sync root tree {}.", tree_id),
- /*fatal=*/no_sync_is_fatal);
- return not no_sync_is_fatal;
- }
- // done!
- return true;
-}
diff --git a/src/other_tools/root_maps/root_utils.hpp b/src/other_tools/root_maps/root_utils.hpp
index 2ba8b5ef..bee3db29 100644
--- a/src/other_tools/root_maps/root_utils.hpp
+++ b/src/other_tools/root_maps/root_utils.hpp
@@ -15,15 +15,11 @@
#ifndef INCLUDED_SRC_OTHER_TOOLS_ROOT_MAPS_ROOT_UTILS_HPP
#define INCLUDED_SRC_OTHER_TOOLS_ROOT_MAPS_ROOT_UTILS_HPP
-#include <filesystem>
#include <optional>
#include <string>
-#include "gsl/gsl"
-#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/multithreading/async_map_consumer.hpp"
#include "src/buildtool/serve_api/remote/serve_api.hpp"
-#include "src/buildtool/storage/config.hpp"
/// \brief Calls the ServeApi to check whether the serve endpoint has the given
/// tree available to build against.
@@ -37,41 +33,4 @@
std::string const& tree_id,
AsyncMapConsumerLoggerPtr const& logger) -> std::optional<bool>;
-/// \brief Calls the ServeApi to instruct the serve endpoint to set up a root
-/// defined by a given tree by retrieving it from the remote CAS. This method
-/// ensures the respective tree is in the remote CAS prior to the ServeApi call
-/// by uploading it to the remote CAS if it is missing.
-/// IMPORTANT: No check is performed for the compatibility mode of the protocol
-/// used by given remote execution endpoint!
-/// \param tree_id The Git-tree identifier.
-/// \param repo_path Local witnessing Git repository for the tree.
-/// \param native_storage_config Configuration of the native local storage.
-/// \param compat_storage_config Optional configuration of the compatible local
-/// storage, if it was set up.
-/// \param compat_storage Optional compatible local storage, if it was set up.
-/// \param local_api Optional API that knows how to communicate with the
-/// remote-execution endpoint specified by parameter remote_api, if given. In
-/// particular, it is expected to be provided if the remote is compatible.
-/// \param remote_api Optional API of the remote-execution endpoint.
-/// If nullopt, skip the upload to the remote CAS; this assumes prior knowledge
-/// which guarantees the tree given by tree_id exists in the remote CAS for the
-/// duration of the subsequent serve API call; this option should be used
-/// carefully, but does result in less remote communication.
-/// \param logger An AsyncMapConsumer logger instance.
-/// \param no_sync_is_fatal If true, report only as a warning the failure of the
-/// serve endpoint to set up the root for this tree; otherwise, this is reported
-/// as fatal.
-/// \returns Status flag, with false if state is deemed fatal, and true
-/// otherwise. Logger is only called with fatal if returning false.
-[[nodiscard]] auto EnsureAbsentRootOnServe(
- ServeApi const& serve,
- std::string const& tree_id,
- std::filesystem::path const& repo_path,
- gsl::not_null<StorageConfig const*> const& native_storage_config,
- StorageConfig const* compat_storage_config,
- IExecutionApi const* local_api,
- IExecutionApi const* remote_api,
- AsyncMapConsumerLoggerPtr const& logger,
- bool no_sync_is_fatal) -> bool;
-
#endif // INCLUDED_SRC_OTHER_TOOLS_ROOT_MAPS_ROOT_UTILS_HPP