From c12882183b4b69099f4d3977329eb61189291d92 Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Fri, 25 Oct 2024 10:30:47 +0200 Subject: bugfix: bazel_network.cpp: fix handling of ongoing actions The rpc Execution::Execute returns stream google.longrunning.Operation. When the client reads the stream, the server can report that the operation is still in progress and the client has to wait. Before this patch, we were not checking for this particular condition. As a result, an ongoing action was interpreted as an execution failure. --- src/buildtool/execution_api/remote/bazel/bazel_execution_client.cpp | 3 +++ src/buildtool/execution_api/remote/bazel/bazel_network.cpp | 6 ++++++ 2 files changed, 9 insertions(+) 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 a2b29d75..8eb26a0c 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_execution_client.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_execution_client.cpp @@ -95,6 +95,9 @@ auto BazelExecutionClient::Execute(std::string const& instance_name, } auto contents = ExtractContents(std::move(op)); response = contents.response; + if (response.state == ExecutionResponse::State::Ongoing) { + return {.ok = true, .exit_retry_loop = true}; + } if (response.state == ExecutionResponse::State::Finished) { return {.ok = true}; } diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp index 0d53643d..34ebb418 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp @@ -131,6 +131,12 @@ auto BazelNetwork::ExecuteBazelActionSync( auto response = exec_->Execute(instance_name_, action, exec_config_, true /*wait*/); + if (response.state == + BazelExecutionClient::ExecutionResponse::State::Ongoing) { + Logger::Log( + LogLevel::Trace, "Waiting for {}", response.execution_handle); + response = exec_->WaitExecution(response.execution_handle); + } if (response.state != BazelExecutionClient::ExecutionResponse::State::Finished or not response.output) { -- cgit v1.2.3