summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/common/TARGETS1
-rw-r--r--src/buildtool/common/repository_config.hpp4
-rw-r--r--src/buildtool/main/main.cpp2
-rw-r--r--src/buildtool/serve_api/remote/serve_api.cpp4
-rw-r--r--src/buildtool/serve_api/serve_service/source_tree.cpp2
-rw-r--r--src/buildtool/tree_structure/tree_structure_utils.cpp6
-rw-r--r--src/buildtool/tree_structure/tree_structure_utils.hpp2
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.cpp15
8 files changed, 25 insertions, 11 deletions
diff --git a/src/buildtool/common/TARGETS b/src/buildtool/common/TARGETS
index 469f074f..f324d767 100644
--- a/src/buildtool/common/TARGETS
+++ b/src/buildtool/common/TARGETS
@@ -189,6 +189,7 @@
, ["src/buildtool/file_system", "precomputed_root"]
, ["src/buildtool/logging", "log_level"]
, ["src/buildtool/multithreading", "atomic_value"]
+ , ["src/buildtool/storage", "config"]
, ["src/buildtool/storage", "storage"]
]
, "stage": ["src", "buildtool", "common"]
diff --git a/src/buildtool/common/repository_config.hpp b/src/buildtool/common/repository_config.hpp
index 68023b8e..1a2f5be1 100644
--- a/src/buildtool/common/repository_config.hpp
+++ b/src/buildtool/common/repository_config.hpp
@@ -34,6 +34,7 @@
#include "src/buildtool/file_system/precomputed_root.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/multithreading/atomic_value.hpp"
+#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/storage/storage.hpp"
class RepositoryConfig {
@@ -64,7 +65,9 @@ class RepositoryConfig {
[[nodiscard]] auto SetGitCAS(
std::filesystem::path const& repo_path,
+ gsl::not_null<StorageConfig const*> const& storage_config,
LogLevel log_level = LogLevel::Warning) noexcept -> bool {
+ storage_config_ = storage_config;
git_cas_ = GitCAS::Open(repo_path, log_level);
return static_cast<bool>(git_cas_);
}
@@ -181,6 +184,7 @@ class RepositoryConfig {
std::unordered_map<std::string, RepositoryData> repos_;
GitCASPtr git_cas_;
+ StorageConfig const* storage_config_ = nullptr;
AtomicValue<duplicates_t> duplicates_;
template <class T>
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index c1b8bcdf..2487a37f 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -1020,6 +1020,7 @@ auto main(int argc, char* argv[]) -> int {
if (arguments.cmd == SubCommand::kInstallCas) {
if (not repo_config.SetGitCAS(storage_config->GitRoot(),
+ &(*storage_config),
LogLevel::Trace)) {
Logger::Log(LogLevel::Debug,
"Failed set Git CAS {}.",
@@ -1082,6 +1083,7 @@ auto main(int argc, char* argv[]) -> int {
return kExitSyntaxError;
}
if (not repo_config.SetGitCAS(*arguments.graph.git_cas,
+ &(*storage_config),
LogLevel::Debug)) {
Logger::Log(LogLevel::Warning,
"Failed set Git CAS {}.",
diff --git a/src/buildtool/serve_api/remote/serve_api.cpp b/src/buildtool/serve_api/remote/serve_api.cpp
index 107f4439..44755820 100644
--- a/src/buildtool/serve_api/remote/serve_api.cpp
+++ b/src/buildtool/serve_api/remote/serve_api.cpp
@@ -35,8 +35,10 @@ auto ServeApi::UploadTree(ArtifactDigest const& tree,
fmt::format("Not a git tree: {}", tree.hash()), not kIsSyncError}};
}
+ // Set up the repository config; compatibility of used storage instance is
+ // irrelevant here, as only the build root path info is needed.
RepositoryConfig repo;
- if (not repo.SetGitCAS(git_repo)) {
+ if (not repo.SetGitCAS(git_repo, &storage_config_)) {
return unexpected{UploadError{
fmt::format("Failed to SetGitCAS at {}", git_repo.string()),
not kIsSyncError}};
diff --git a/src/buildtool/serve_api/serve_service/source_tree.cpp b/src/buildtool/serve_api/serve_service/source_tree.cpp
index 7ffe176e..35d5797a 100644
--- a/src/buildtool/serve_api/serve_service/source_tree.cpp
+++ b/src/buildtool/serve_api/serve_service/source_tree.cpp
@@ -370,7 +370,7 @@ auto SourceTreeService::SyncGitEntryToCas(
}
auto repo = RepositoryConfig{};
- if (not repo.SetGitCAS(repo_path)) {
+ if (not repo.SetGitCAS(repo_path, native_context_->storage_config)) {
logger_->Emit(
LogLevel::Error, "Failed to SetGitCAS at {}", repo_path.string());
return TResponse::INTERNAL_ERROR;
diff --git a/src/buildtool/tree_structure/tree_structure_utils.cpp b/src/buildtool/tree_structure/tree_structure_utils.cpp
index f09d627b..758e47fc 100644
--- a/src/buildtool/tree_structure/tree_structure_utils.cpp
+++ b/src/buildtool/tree_structure/tree_structure_utils.cpp
@@ -208,6 +208,7 @@ auto TreeStructureUtils::ImportToGit(
auto TreeStructureUtils::ExportFromGit(
ArtifactDigest const& tree,
std::vector<std::filesystem::path> const& source_repos,
+ StorageConfig const& storage_config,
IExecutionApi const& target_api) noexcept -> expected<bool, std::string> {
if (not tree.IsTree() or not ProtocolTraits::IsNative(tree.GetHashType())) {
return unexpected{fmt::format("Not a git tree: {}", tree.hash())};
@@ -231,7 +232,7 @@ auto TreeStructureUtils::ExportFromGit(
}
RepositoryConfig repo_config{};
- if (not repo_config.SetGitCAS(*repo)) {
+ if (not repo_config.SetGitCAS(*repo, &storage_config)) {
return unexpected{
fmt::format("Failed to set git cas at {}", repo->string())};
}
@@ -276,7 +277,8 @@ auto TreeStructureUtils::ComputeStructureLocally(
// If the tree is not in the storage, it must be present in git:
if (not storage.CAS().TreePath(tree).has_value()) {
- auto in_cas = ExportFromGit(tree, known_repositories, local_api);
+ auto in_cas =
+ ExportFromGit(tree, known_repositories, storage_config, local_api);
if (not in_cas.has_value()) {
return unexpected{
fmt::format("While exporting {} from git to CAS:\n{}",
diff --git a/src/buildtool/tree_structure/tree_structure_utils.hpp b/src/buildtool/tree_structure/tree_structure_utils.hpp
index 7cecf7f8..93615cf0 100644
--- a/src/buildtool/tree_structure/tree_structure_utils.hpp
+++ b/src/buildtool/tree_structure/tree_structure_utils.hpp
@@ -67,12 +67,14 @@ class TreeStructureUtils final {
/// regular GitApi for retrieval from git and doesn't perform rehashing.
/// \param tree Tree to export
/// \param source_repos Repositories to check
+ /// \param storage_config Storage to use for lookups
/// \param target_api Api to export the tree to
/// \return True if target api contains tree after the call, false if none
/// of source repositories contain tree, or an error message on failure.
[[nodiscard]] static auto ExportFromGit(
ArtifactDigest const& tree,
std::vector<std::filesystem::path> const& source_repos,
+ StorageConfig const& storage_config,
IExecutionApi const& target_api) noexcept
-> expected<bool, std::string>;
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 9a539a51..34c693a7 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
@@ -41,17 +41,18 @@
namespace {
void BackupToRemote(ArtifactDigest const& digest,
- StorageConfig const& native_storage_config,
+ StorageConfig const* native_storage_config,
StorageConfig const* compat_storage_config,
gsl::not_null<IExecutionApi const*> const& local_api,
IExecutionApi const& remote_api,
GitTreeFetchMap::LoggerPtr const& logger) {
// try to back up to remote CAS
auto repo = RepositoryConfig{};
- if (repo.SetGitCAS(native_storage_config.GitRoot())) {
+ if (repo.SetGitCAS(native_storage_config->GitRoot(),
+ native_storage_config)) {
auto git_api =
MRGitApi{&repo,
- &native_storage_config,
+ native_storage_config,
compat_storage_config,
compat_storage_config != nullptr ? &*local_api : nullptr};
if (git_api.RetrieveToCas(
@@ -123,7 +124,7 @@ void MoveCASTreeToGit(
// back up only native digests, as that is what Git stores
auto const native_digest = ArtifactDigest{tree_hash, 0};
BackupToRemote(native_digest,
- *native_storage_config,
+ native_storage_config,
compat_storage_config,
local_api,
*remote_api,
@@ -180,7 +181,7 @@ void TagAndSetRoot(
// backup to remote if needed and in compatibility mode
if (backup_to_remote and remote_api != nullptr) {
BackupToRemote(digest,
- *native_storage_config,
+ native_storage_config,
compat_storage_config,
local_api,
*remote_api,
@@ -378,7 +379,7 @@ auto CreateGitTreeFetchMap(
// backup to remote if needed
if (backup_to_remote and remote_api != nullptr) {
BackupToRemote(ArtifactDigest{key.tree_hash, 0},
- *native_storage_config,
+ native_storage_config,
compat_storage_config,
local_api,
*remote_api,
@@ -732,7 +733,7 @@ auto CreateGitTreeFetchMap(
remote_api != nullptr) {
BackupToRemote(
ArtifactDigest{key.tree_hash, 0},
- *native_storage_config,
+ native_storage_config,
compat_storage_config,
local_api,
*remote_api,