diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2024-10-25 10:30:47 +0200 |
---|---|---|
committer | Alberto Sartori <alberto.sartori@huawei.com> | 2024-10-25 11:24:50 +0200 |
commit | c12882183b4b69099f4d3977329eb61189291d92 (patch) | |
tree | fbcae08d90a68f5ee18b3ac52690a501a56f8430 | |
parent | a7646c85398277ee7a3ff6d66da6503e6c25e97b (diff) | |
download | justbuild-c12882183b4b69099f4d3977329eb61189291d92.tar.gz |
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.
-rw-r--r-- | src/buildtool/execution_api/remote/bazel/bazel_execution_client.cpp | 3 | ||||
-rw-r--r-- | src/buildtool/execution_api/remote/bazel/bazel_network.cpp | 6 |
2 files changed, 9 insertions, 0 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 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) { |