summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-09-12 18:07:03 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-09-16 10:01:34 +0200
commita9ec80795740dd33a1bcf18f43e30f473bf90dc7 (patch)
treea19972fe30b519d3fc2dd5bc61048853ba80fc8e /src
parent49c2382ea5ea45966ef15140fce6ad89672e956c (diff)
downloadjustbuild-a9ec80795740dd33a1bcf18f43e30f473bf90dc7.tar.gz
bazel_response: Improve error reporting for uploading trees
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_response.cpp17
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_response.hpp4
2 files changed, 11 insertions, 10 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
index 468a2531..e089888a 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
@@ -215,10 +215,8 @@ auto BazelResponse::Populate() noexcept -> std::optional<std::string> {
// have to upload them manually.
auto root_digest = UploadTreeMessageDirectories(*tree);
if (not root_digest) {
- auto const error = fmt::format(
- "BazelResponse: failure in uploading Tree Directory "
- "message for {}",
- tree_blob.digest.hash());
+ auto const error =
+ fmt::format("BazelResponse: {}", root_digest.error());
Logger::Log(LogLevel::Trace, error);
return error;
}
@@ -242,7 +240,7 @@ auto BazelResponse::Populate() noexcept -> std::optional<std::string> {
}
auto BazelResponse::UploadTreeMessageDirectories(
- bazel_re::Tree const& tree) const -> std::optional<ArtifactDigest> {
+ bazel_re::Tree const& tree) const -> expected<ArtifactDigest, std::string> {
auto const upload_callback =
[&network = *network_](BazelBlobContainer&& blobs) -> bool {
return network.UploadBlobs(std::move(blobs));
@@ -258,7 +256,8 @@ auto BazelResponse::UploadTreeMessageDirectories(
std::move(rootdir_blob),
/*exception_is_fatal=*/false,
upload_callback)) {
- return std::nullopt;
+ return unexpected{fmt::format("failed to upload root for Tree {}",
+ tree.SerializeAsString())};
}
for (auto const& subdir : tree.children()) {
@@ -268,13 +267,15 @@ auto BazelResponse::UploadTreeMessageDirectories(
ProcessDirectoryMessage(hash_function, subdir),
/*exception_is_fatal=*/false,
upload_callback)) {
- return std::nullopt;
+ return unexpected{fmt::format("failed to upload subdir for Tree {}",
+ tree.SerializeAsString())};
}
}
// upload any remaining blob
if (not std::invoke(upload_callback, std::move(dir_blobs))) {
- return std::nullopt;
+ return unexpected{fmt::format("failed to upload blobs for Tree {}",
+ tree.SerializeAsString())};
}
return ArtifactDigestFactory::FromBazel(hash_function.GetType(),
root_digest)
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_response.hpp b/src/buildtool/execution_api/remote/bazel/bazel_response.hpp
index ec3e9748..7c095645 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_response.hpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_response.hpp
@@ -92,8 +92,8 @@ class BazelResponse final : public IExecutionResponse {
/// \returns Error message on failure, nullopt on success.
[[nodiscard]] auto Populate() noexcept -> std::optional<std::string>;
- [[nodiscard]] auto UploadTreeMessageDirectories(
- bazel_re::Tree const& tree) const -> std::optional<ArtifactDigest>;
+ [[nodiscard]] auto UploadTreeMessageDirectories(bazel_re::Tree const& tree)
+ const -> expected<ArtifactDigest, std::string>;
};
#endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_BAZEL_BAZEL_RESPONSE_HPP