summaryrefslogtreecommitdiff
path: root/src/buildtool/serve_api/serve_service/target.cpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-12-21 14:35:19 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-12-21 17:37:27 +0100
commit47506ac266a52cd3eafe00fccd80fad596417a79 (patch)
tree18211a8168ae50e582bf19aad3fc23349764e22f /src/buildtool/serve_api/serve_service/target.cpp
parent8f55914a9879c4687696d8da57bb9dc5e261e2df (diff)
downloadjustbuild-47506ac266a52cd3eafe00fccd80fad596417a79.tar.gz
serve target handling: store blobs also locally
... before trying to upload from local storage to the remote CAS. Co-authored-by: Alberto Sartori <alberto.sartori@huawei.com>
Diffstat (limited to 'src/buildtool/serve_api/serve_service/target.cpp')
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index c03e729b..b2cd06db 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -140,10 +140,18 @@ auto TargetService::ServeTarget(
auto const description_str = description.dump(
2, ' ', false, nlohmann::json::error_handler_t::replace);
auto execution_backend_dgst =
- ArtifactDigest::Create<ObjectType::File>(description_str);
- auto const& execution_info =
- Artifact::ObjectInfo{.digest = ArtifactDigest{execution_backend_dgst},
- .type = ObjectType::File};
+ Storage::Instance().CAS().StoreBlob(description_str);
+ if (not execution_backend_dgst) {
+ logger_->Emit(
+ LogLevel::Error,
+ "Failed to store execution backend description in local CAS");
+ return ::grpc::Status{
+ ::grpc::StatusCode::INTERNAL,
+ "Failed to store execution backend description in local CAS"};
+ }
+ auto untagged_execution_backend = ArtifactDigest{*execution_backend_dgst};
+ auto const& execution_info = Artifact::ObjectInfo{
+ .digest = untagged_execution_backend, .type = ObjectType::File};
if (!local_api_->RetrieveToCas({execution_info}, &*remote_api_)) {
auto msg = fmt::format("Failed to upload blob {} to remote CAS",
execution_info.ToString());
@@ -153,7 +161,7 @@ auto TargetService::ServeTarget(
// get a target cache instance with the correct computed shard
auto const& tc = Storage::Instance().TargetCache().WithShard(
- execution_backend_dgst.hash());
+ untagged_execution_backend.hash());
auto const& tc_key =
TargetCacheKey{{target_cache_key_digest, ObjectType::File}};