From ab0a06871391a84c9b904bc9f2cd74ee1e8903ea Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 14 May 2024 14:44:29 +0200 Subject: 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. --- src/buildtool/build_engine/target_map/export.cpp | 61 ++++++++++++++---------- 1 file changed, 37 insertions(+), 24 deletions(-) (limited to 'src/buildtool/build_engine/target_map/export.cpp') 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); -- cgit v1.2.3