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
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-05-21 15:09:17 +0200
commit9e888fe80a835b084a28f7b9cb4b5759b4eaf47a (patch)
tree8cb0beaabdcaaef6e46bbb8d690c98a4295e9bdc /src/buildtool/serve_api/remote/target_client.cpp
parent87d4eac4664ff520890000d68ce43b493df171a3 (diff)
downloadjustbuild-9e888fe80a835b084a28f7b9cb4b5759b4eaf47a.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. (cherry picked from ab0a06871391a84c9b904bc9f2cd74ee1e8903ea)
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())};
}