diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2023-02-13 15:48:30 +0100 |
---|---|---|
committer | Alberto Sartori <alberto.sartori@huawei.com> | 2023-02-15 16:41:10 +0100 |
commit | 1576b65e9365335aa7a2ed287eceaf93fbfac88a (patch) | |
tree | 4907670d8205cf87d2ce0b8a81b6141086313e4b /src/buildtool/execution_api/execution_service/execution_server.cpp | |
parent | 9db8ca6f2a95e83849faa9b35860bc2326072b6c (diff) | |
download | justbuild-1576b65e9365335aa7a2ed287eceaf93fbfac88a.tar.gz |
just execute: add more logs during execution
Diffstat (limited to 'src/buildtool/execution_api/execution_service/execution_server.cpp')
-rw-r--r-- | src/buildtool/execution_api/execution_service/execution_server.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/buildtool/execution_api/execution_service/execution_server.cpp b/src/buildtool/execution_api/execution_service/execution_server.cpp index 3d33b704..d3c05b94 100644 --- a/src/buildtool/execution_api/execution_service/execution_server.cpp +++ b/src/buildtool/execution_api/execution_service/execution_server.cpp @@ -35,46 +35,48 @@ auto ExecutionServiceImpl::Execute( } auto path = storage_.BlobPath(request->action_digest(), false); if (!path) { - return ::grpc::Status{grpc::StatusCode::INTERNAL, - fmt::format("could not retrieve blob {} from cas", - request->action_digest().hash())}; + auto const& str = fmt::format("could not retrieve blob {} from cas", + request->action_digest().hash()); + logger_.Emit(LogLevel::Error, str); + return ::grpc::Status{grpc::StatusCode::INTERNAL, str}; } ::build::bazel::remote::execution::v2::Action a{}; { std::ifstream f(*path); if (!a.ParseFromIstream(&f)) { - return ::grpc::Status{ - grpc::StatusCode::INTERNAL, - fmt::format("failed to parse action from blob {}", - request->action_digest().hash())}; + auto const& str = fmt::format("failed to parse action from blob {}", + request->action_digest().hash()); + logger_.Emit(LogLevel::Error, str); + return ::grpc::Status{grpc::StatusCode::INTERNAL, str}; } } path = storage_.BlobPath(a.command_digest(), false); if (!path) { - return ::grpc::Status{grpc::StatusCode::INTERNAL, - fmt::format("could not retrieve blob {} from cas", - request->action_digest().hash())}; + auto const& str = fmt::format("could not retrieve blob {} from cas", + a.command_digest().hash()); + logger_.Emit(LogLevel::Error, str); + return ::grpc::Status{grpc::StatusCode::INTERNAL, str}; } ::build::bazel::remote::execution::v2::Command c{}; { std::ifstream f(*path); if (!c.ParseFromIstream(&f)) { - return ::grpc::Status{ - grpc::StatusCode::INTERNAL, + auto const& str = fmt::format("failed to parse command from blob {}", - a.command_digest().hash())}; + a.command_digest().hash()); + return ::grpc::Status{grpc::StatusCode::INTERNAL, str}; } } - if (Compatibility::IsCompatible()) { - path = storage_.BlobPath(a.input_root_digest(), false); - } - else { - path = storage_.TreePath(a.input_root_digest()); - } + path = Compatibility::IsCompatible() + ? storage_.BlobPath(a.input_root_digest(), false) + : storage_.TreePath(a.input_root_digest()); + if (!path) { - return ::grpc::Status{grpc::StatusCode::INTERNAL, - fmt::format("could not retrieve tree {} from cas", - a.input_root_digest().hash())}; + auto const& str = + fmt::format("could not retrieve input root {} from cas", + a.input_root_digest().hash()); + logger_.Emit(LogLevel::Error, str); + return ::grpc::Status{grpc::StatusCode::INTERNAL, str}; } auto op = ::google::longrunning::Operation{}; op.set_name("just-remote-execution"); @@ -95,6 +97,9 @@ auto ExecutionServiceImpl::Execute( logger_.Emit(LogLevel::Info, "Execute {}", request->action_digest().hash()); auto tmp = action->Execute(&logger_); + logger_.Emit(LogLevel::Trace, + "Finished execution of {}", + request->action_digest().hash()); ::build::bazel::remote::execution::v2::ExecuteResponse response{}; for (auto const& [path, info] : tmp->Artifacts()) { if (info.type == ObjectType::Tree) { |