summaryrefslogtreecommitdiff
path: root/src/buildtool/serve_api/remote/target_client.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-05-14 14:44:29 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-05-15 17:05:01 +0200
commitab0a06871391a84c9b904bc9f2cd74ee1e8903ea (patch)
treece2096d7ef578ebc76f8b6e2c6aeee668b797507 /src/buildtool/serve_api/remote/target_client.cpp
parent0fd32f8b9d707d807c236156de12118b0a695d69 (diff)
downloadjustbuild-ab0a06871391a84c9b904bc9f2cd74ee1e8903ea.tar.gz
serve target: Improve logic for local build failure triggers
If the serve endpoint reports an internal error, local builds should not continue and the error message should be provided. Similarly, if the serve endpoint promises the target cache value to be in remote CAS, but the client cannot find or process it as needed, then a local build again should not continue and the reason be provided as an error message.
Diffstat (limited to 'src/buildtool/serve_api/remote/target_client.cpp')
-rw-r--r--src/buildtool/serve_api/remote/target_client.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/buildtool/serve_api/remote/target_client.cpp b/src/buildtool/serve_api/remote/target_client.cpp
index d64f24c8..67b50a84 100644
--- a/src/buildtool/serve_api/remote/target_client.cpp
+++ b/src/buildtool/serve_api/remote/target_client.cpp
@@ -100,10 +100,6 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key,
grpc::ClientContext context;
justbuild::just_serve::ServeTargetResponse response;
auto const& status = stub_->ServeTarget(&context, request, &response);
- if (!status.ok()) {
- return serve_target_result_t{std::in_place_index<1>,
- StatusString(status)};
- }
// differentiate status codes
switch (status.error_code()) {
@@ -145,7 +141,7 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key,
auto const& result = TargetCacheEntry::FromJson(
nlohmann::json::parse(*target_value_str));
// return the target cache value information
- return serve_target_result_t{std::in_place_index<2>,
+ return serve_target_result_t{std::in_place_index<3>,
std::make_pair(result, obj_info)};
} catch (std::exception const& ex) {
return serve_target_result_t{
@@ -154,13 +150,20 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key,
ex.what())};
}
}
+ case grpc::StatusCode::INTERNAL: {
+ return serve_target_result_t{
+ std::in_place_index<1>,
+ fmt::format(
+ "Serve endpoint reported the fatal internal error:\n{}",
+ status.error_message())};
+ }
case grpc::StatusCode::NOT_FOUND: {
return std::nullopt; // this might allow a local build to continue
}
default:; // fallthrough
}
return serve_target_result_t{
- std::in_place_index<1>,
+ std::in_place_index<2>,
fmt::format("Serve endpoint failed with:\n{}", status.error_message())};
}