summaryrefslogtreecommitdiff
path: root/src/buildtool/build_engine/target_map/export.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/build_engine/target_map/export.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/build_engine/target_map/export.cpp')
-rw-r--r--src/buildtool/build_engine/target_map/export.cpp61
1 files changed, 37 insertions, 24 deletions
diff --git a/src/buildtool/build_engine/target_map/export.cpp b/src/buildtool/build_engine/target_map/export.cpp
index e0bc36c3..e92d4c9c 100644
--- a/src/buildtool/build_engine/target_map/export.cpp
+++ b/src/buildtool/build_engine/target_map/export.cpp
@@ -160,31 +160,44 @@ void ExportRule(
key.target.ToString());
}
else {
- if (res->index() == 0) {
- // target found but failed to analyse/build: this should be
- // a fatal error for the local build too
- (*logger)(
- fmt::format("Failure to remotely analyse or build "
- "target {}\nDetailed log available on the "
- "remote-execution endpoint as blob {}",
- key.target.ToString(),
- std::get<0>(*res)),
- /*fatal=*/true);
- return;
- }
- if (res->index() == 1) {
- // some other failure occurred while querying the serve
- // endpoint; log to debug and continue locally
- Logger::Log(LogLevel::Debug,
- "While querying serve endpoint for export "
- "target {}:\n{}",
+ switch (res->index()) {
+ case 0: {
+ // target found but failed to analyse/build: this should
+ // be a fatal error for the local build too
+ (*logger)(
+ fmt::format(
+ "Failure to remotely analyse or build target "
+ "{}\nDetailed log available on the "
+ "remote-execution endpoint as blob {}",
key.target.ToString(),
- std::get<1>(*res));
- }
- else {
- // index == 2
- target_cache_value = std::get<2>(*res);
- from_just_serve = true;
+ std::get<0>(*res)),
+ /*fatal=*/true);
+ return;
+ }
+ case 1: {
+ // internal failure on the serve endpoint, or failures
+ // on the client side: local build should not continue
+ (*logger)(fmt::format("While querying serve endpoint "
+ "for export target {}:\n{}",
+ key.target.ToString(),
+ std::get<1>(*res)),
+ /*fatal=*/true);
+ return;
+ }
+ case 2: {
+ // some other failure occurred on the serve endpoint;
+ // log to debug and continue locally
+ Logger::Log(LogLevel::Debug,
+ "While querying serve endpoint for export "
+ "target {}:\n{}",
+ key.target.ToString(),
+ std::get<2>(*res));
+ } break;
+ default: {
+ // index == 3
+ target_cache_value = std::get<3>(*res);
+ from_just_serve = true;
+ }
}
}
exports_progress->TaskTracker().Stop(task);