summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_execution_client.cpp37
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network.cpp3
2 files changed, 36 insertions, 4 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_execution_client.cpp b/src/buildtool/execution_api/remote/bazel/bazel_execution_client.cpp
index 735f3b45..d58d6d06 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_execution_client.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_execution_client.cpp
@@ -6,6 +6,31 @@
namespace bazel_re = build::bazel::remote::execution::v2;
+namespace {
+
+void LogExecutionStatus(gsl::not_null<Logger const*> const& logger,
+ google::rpc::Status const& s) noexcept {
+ switch (s.code()) {
+ case grpc::StatusCode::DEADLINE_EXCEEDED:
+ logger->Emit(LogLevel::Error, "Execution timed out.");
+ break;
+ case grpc::StatusCode::UNAVAILABLE:
+ // quote from remote_execution.proto:
+ // Due to a transient condition, such as all workers being occupied
+ // (and the server does not support a queue), the action could not
+ // be started. The client should retry.
+ logger->Emit(LogLevel::Error,
+ "Execution could not be started. Retry later.");
+ break;
+ default:
+ // fallback to default status logging
+ LogStatus(logger, LogLevel::Debug, s);
+ break;
+ }
+}
+
+} // namespace
+
BazelExecutionClient::BazelExecutionClient(std::string const& server,
Port port,
std::string const& user,
@@ -109,7 +134,6 @@ auto BazelExecutionClient::ExtractContents(
// Get execution response Unpacked from Protobufs Any type to the actual
// type in our case
- bazel_re::ExecuteResponse exec_response;
auto const& raw_response = op.response();
if (not raw_response.Is<bazel_re::ExecuteResponse>()) {
// Fatal error, the type should be correct
@@ -117,16 +141,23 @@ auto BazelExecutionClient::ExtractContents(
return response;
}
- response.state = ExecutionResponse::State::Finished;
-
+ bazel_re::ExecuteResponse exec_response;
raw_response.UnpackTo(&exec_response);
+ if (exec_response.status().code() != grpc::StatusCode::OK) {
+ // For now, treat all execution errors (e.g., action timeout) as fatal.
+ LogExecutionStatus(&logger_, exec_response.status());
+ response.state = ExecutionResponse::State::Failed;
+ return response;
+ }
+
ExecutionOutput output;
output.action_result = exec_response.result();
output.cached_result = exec_response.cached_result();
output.message = exec_response.message();
output.server_logs = exec_response.server_logs();
response.output = output;
+ response.state = ExecutionResponse::State::Finished;
return response;
}
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
index ee31d5ee..669f93dd 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
@@ -146,7 +146,8 @@ auto BazelNetwork::ExecuteBazelActionSync(
if (response.state !=
BazelExecutionClient::ExecutionResponse::State::Finished or
not response.output) {
- // TODO(oreiche): logging
+ Logger::Log(
+ LogLevel::Error, "Failed to execute action {}.", action.hash());
return std::nullopt;
}