From ba28beba51ff7d495e5165471b96f7496bf585c2 Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Thu, 13 Jul 2023 13:20:59 +0200 Subject: bytestream_server: store temporary files under the local-buil-root The bytestream server implementation (deployed by just execute) now stores the temporary files under $local_build_root/protocol-depenedent/generation-0 so that they can be garbage collected if "just exectue" is terminated before they are cleaned up. --- .../execution_service/bytestream_server.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/buildtool/execution_api/execution_service/bytestream_server.cpp') diff --git a/src/buildtool/execution_api/execution_service/bytestream_server.cpp b/src/buildtool/execution_api/execution_service/bytestream_server.cpp index 234c4adc..b450c697 100644 --- a/src/buildtool/execution_api/execution_service/bytestream_server.cpp +++ b/src/buildtool/execution_api/execution_service/bytestream_server.cpp @@ -113,7 +113,14 @@ auto BytestreamServiceImpl::Write( *hash, request.write_offset(), request.finish_write()); - auto tmp_dir = TmpDir::Create("execution-service"); + auto lock = GarbageCollector::SharedLock(); + if (!lock) { + auto str = fmt::format("Could not acquire SharedLock"); + logger_.Emit(LogLevel::Error, str); + return grpc::Status{grpc::StatusCode::INTERNAL, str}; + } + auto tmp_dir = TmpDir::Create(StorageConfig::GenerationCacheRoot(0) / + "execution-service"); if (!tmp_dir) { return ::grpc::Status{::grpc::StatusCode::INTERNAL, "could not create TmpDir"}; @@ -129,21 +136,16 @@ auto BytestreamServiceImpl::Write( of.write(request.data().data(), static_cast(request.data().size())); } - auto lock = GarbageCollector::SharedLock(); - if (!lock) { - auto str = fmt::format("Could not acquire SharedLock"); - logger_.Emit(LogLevel::Error, str); - return grpc::Status{grpc::StatusCode::INTERNAL, str}; - } if (NativeSupport::IsTree(*hash)) { - if (not storage_->CAS().StoreTree(tmp)) { + if (not storage_->CAS().StoreTree(tmp)) { auto str = fmt::format("could not store tree {}", *hash); logger_.Emit(LogLevel::Error, str); return ::grpc::Status{::grpc::StatusCode::INVALID_ARGUMENT, str}; } } else { - if (not storage_->CAS().StoreBlob(tmp, /*is_executable=*/false)) { + if (not storage_->CAS().StoreBlob( + tmp, /*is_executable=*/false)) { auto str = fmt::format("could not store blob {}", *hash); logger_.Emit(LogLevel::Error, str); return ::grpc::Status{::grpc::StatusCode::INVALID_ARGUMENT, str}; -- cgit v1.2.3