summaryrefslogtreecommitdiff
path: root/src/buildtool/serve_api/serve_service/target.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildtool/serve_api/serve_service/target.cpp')
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index cc21a7be..6afea7e0 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -39,8 +39,6 @@
#include "src/buildtool/progress_reporting/progress.hpp"
#include "src/buildtool/progress_reporting/progress_reporter.hpp"
#include "src/buildtool/serve_api/serve_service/target_utils.hpp"
-#include "src/buildtool/storage/config.hpp"
-#include "src/buildtool/storage/storage.hpp"
#include "src/buildtool/storage/target_cache_key.hpp"
#include "src/utils/cpp/verify_hash.hpp"
@@ -91,7 +89,7 @@ auto TargetService::HandleFailureLog(
logfile.string());
});
// ...but try to give the client the proper log
- auto const& cas = Storage::Instance().CAS();
+ auto const& cas = storage_.CAS();
auto digest = cas.StoreBlob(logfile, /*is_executable=*/false);
if (not digest) {
auto msg = fmt::format("Failed to store log of failed {} to local CAS",
@@ -129,7 +127,7 @@ auto TargetService::ServeTarget(
ArtifactDigest{request->target_cache_key_id()};
// acquire lock for CAS
- auto lock = GarbageCollector::SharedLock(StorageConfig::Instance());
+ auto lock = GarbageCollector::SharedLock(storage_config_);
if (!lock) {
auto msg = std::string("Could not acquire gc SharedLock");
logger_->Emit(LogLevel::Error, msg);
@@ -198,8 +196,7 @@ auto TargetService::ServeTarget(
logger_->Emit(LogLevel::Error, err);
return ::grpc::Status{::grpc::StatusCode::INTERNAL, err};
}
- auto execution_backend_dgst =
- Storage::Instance().CAS().StoreBlob(description_str);
+ auto execution_backend_dgst = storage_.CAS().StoreBlob(description_str);
if (not execution_backend_dgst) {
std::string err{
"Failed to store execution backend description in local CAS"};
@@ -212,7 +209,7 @@ auto TargetService::ServeTarget(
address
? std::make_optional(ArtifactDigest(*execution_backend_dgst).hash())
: std::nullopt;
- auto const& tc = Storage::Instance().TargetCache().WithShard(shard);
+ auto const& tc = storage_.TargetCache().WithShard(shard);
auto const& tc_key =
TargetCacheKey{{target_cache_key_digest, ObjectType::File}};
@@ -336,8 +333,8 @@ auto TargetService::ServeTarget(
logger_->Emit(LogLevel::Error, "{}", msg);
return ::grpc::Status{::grpc::StatusCode::FAILED_PRECONDITION, msg};
}
- auto repo_config_path = Storage::Instance().CAS().BlobPath(
- repo_key_dgst, /*is_executable=*/false);
+ auto repo_config_path =
+ storage_.CAS().BlobPath(repo_key_dgst, /*is_executable=*/false);
if (not repo_config_path) {
// This should not fail unless something went really bad...
auto msg = fmt::format(
@@ -351,6 +348,7 @@ auto TargetService::ServeTarget(
RepositoryConfig repository_config{};
std::string const main_repo{"0"}; // known predefined main repository name
if (auto msg = DetermineRoots(serve_config_,
+ storage_config_,
main_repo,
*repo_config_path,
&repository_config,
@@ -435,7 +433,7 @@ auto TargetService::ServeTarget(
Progress progress{};
// setup logging for analysis and build; write into a temporary file
- auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir("serve-target");
+ auto tmp_dir = storage_config_.CreateTypedTmpDir("serve-target");
if (!tmp_dir) {
auto msg = std::string("Could not create TmpDir");
logger_->Emit(LogLevel::Error, msg);
@@ -592,10 +590,8 @@ auto TargetService::ServeTargetVariables(
std::optional<std::string> target_file_content{std::nullopt};
bool tree_found{false};
// try in local build root Git cache
- if (auto res = GetBlobContent(StorageConfig::Instance().GitRoot(),
- root_tree,
- target_file,
- logger_)) {
+ if (auto res = GetBlobContent(
+ storage_config_.GitRoot(), root_tree, target_file, logger_)) {
tree_found = true;
if (res->first) {
if (not res->second) {
@@ -748,10 +744,8 @@ auto TargetService::ServeTargetDescription(
std::optional<std::string> target_file_content{std::nullopt};
bool tree_found{false};
// try in local build root Git cache
- if (auto res = GetBlobContent(StorageConfig::Instance().GitRoot(),
- root_tree,
- target_file,
- logger_)) {
+ if (auto res = GetBlobContent(
+ storage_config_.GitRoot(), root_tree, target_file, logger_)) {
tree_found = true;
if (res->first) {
if (not res->second) {
@@ -880,7 +874,7 @@ auto TargetService::ServeTargetDescription(
}
// acquire lock for CAS
- auto lock = GarbageCollector::SharedLock(StorageConfig::Instance());
+ auto lock = GarbageCollector::SharedLock(storage_config_);
if (!lock) {
auto error_msg = fmt::format("Could not acquire gc SharedLock");
logger_->Emit(LogLevel::Error, error_msg);
@@ -901,9 +895,8 @@ auto TargetService::ServeTargetDescription(
logger_->Emit(LogLevel::Error, err);
return ::grpc::Status{::grpc::StatusCode::INTERNAL, err};
}
- if (auto dgst =
- Storage::Instance().CAS().StoreBlob(description_str,
- /*is_executable=*/false)) {
+ if (auto dgst = storage_.CAS().StoreBlob(description_str,
+ /*is_executable=*/false)) {
auto const& artifact_dgst = ArtifactDigest{*dgst};
if (not apis_.local->RetrieveToCas(
{Artifact::ObjectInfo{.digest = artifact_dgst,