summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp19
-rw-r--r--src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp7
-rw-r--r--src/buildtool/execution_api/common/common_api.cpp31
-rw-r--r--src/buildtool/execution_api/git/TARGETS1
-rw-r--r--src/buildtool/execution_api/git/git_api.hpp51
-rw-r--r--src/buildtool/execution_api/local/TARGETS2
-rw-r--r--src/buildtool/execution_api/local/local_api.hpp23
-rw-r--r--src/buildtool/execution_api/remote/TARGETS2
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp25
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_response.cpp30
-rw-r--r--src/buildtool/execution_engine/executor/TARGETS2
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp22
-rw-r--r--src/buildtool/graph_traverser/TARGETS3
-rw-r--r--src/buildtool/graph_traverser/graph_traverser.hpp22
14 files changed, 162 insertions, 78 deletions
diff --git a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
index 4be46db2..1827b35f 100644
--- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
+++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
@@ -419,7 +419,7 @@ template <class T>
std::string const& root_name,
DirectoryTreePtr const& tree,
BazelMsgFactory::LinkDigestResolveFunc const& resolve_links,
- std::optional<BazelMsgFactory::BlobStoreFunc> const& store_blob,
+ std::optional<BazelMsgFactory::BlobProcessFunc> const& process_blob,
std::optional<BazelMsgFactory::InfoStoreFunc> const& store_info,
std::filesystem::path const& parent = "") noexcept
-> DirectoryNodeBundle::Ptr {
@@ -434,15 +434,16 @@ template <class T>
auto const dir_bundle = DirectoryTreeToBundle(name,
dir,
resolve_links,
- store_blob,
+ process_blob,
store_info,
parent / name);
if (not dir_bundle) {
return nullptr;
}
dir_nodes.emplace_back(dir_bundle->Message());
- if (store_blob) {
- (*store_blob)(dir_bundle->MakeBlob(/*is_exec=*/false));
+ if (process_blob and not(*process_blob)(dir_bundle->MakeBlob(
+ /*is_exec=*/false))) {
+ return nullptr;
}
}
else {
@@ -544,14 +545,16 @@ auto BazelMsgFactory::ReadObjectInfosFromGitTree(
auto BazelMsgFactory::CreateDirectoryDigestFromTree(
DirectoryTreePtr const& tree,
LinkDigestResolveFunc const& resolve_links,
- std::optional<BlobStoreFunc> const& store_blob,
+ std::optional<BlobProcessFunc> const& process_blob,
std::optional<InfoStoreFunc> const& store_info) noexcept
-> std::optional<bazel_re::Digest> {
if (auto bundle = DirectoryTreeToBundle(
- "", tree, resolve_links, store_blob, store_info)) {
- if (store_blob) {
+ "", tree, resolve_links, process_blob, store_info)) {
+ if (process_blob) {
try {
- (*store_blob)(bundle->MakeBlob(/*is_exec=*/false));
+ if (not(*process_blob)(bundle->MakeBlob(/*is_exec=*/false))) {
+ return std::nullopt;
+ }
} catch (...) {
return std::nullopt;
}
diff --git a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp
index 5ba658cb..9ac19088 100644
--- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp
+++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp
@@ -39,6 +39,9 @@
/// communication.
class BazelMsgFactory {
public:
+ /// \brief Store or otherwise process a blob. Returns success flag.
+ using BlobProcessFunc = std::function<bool(BazelBlob&&)>;
+ /// \brief Store blob.
using BlobStoreFunc = std::function<void(BazelBlob&&)>;
using InfoStoreFunc = std::function<bool(std::filesystem::path const&,
Artifact::ObjectInfo const&)>;
@@ -72,13 +75,13 @@ class BazelMsgFactory {
/// Recursively traverse entire tree and create blobs for sub-directories.
/// \param tree Directory tree of artifacts.
/// \param resolve_links Function for resolving symlinks.
- /// \param store_blob Function for storing Directory blobs.
+ /// \param process_blob Function for processing Directory blobs.
/// \param store_info Function for storing object infos.
/// \returns Digest representing the entire tree.
[[nodiscard]] static auto CreateDirectoryDigestFromTree(
DirectoryTreePtr const& tree,
LinkDigestResolveFunc const& resolve_links,
- std::optional<BlobStoreFunc> const& store_blob = std::nullopt,
+ std::optional<BlobProcessFunc> const& process_blob = std::nullopt,
std::optional<InfoStoreFunc> const& store_info = std::nullopt) noexcept
-> std::optional<bazel_re::Digest>;
diff --git a/src/buildtool/execution_api/common/common_api.cpp b/src/buildtool/execution_api/common/common_api.cpp
index 916ba409..be7fa53c 100644
--- a/src/buildtool/execution_api/common/common_api.cpp
+++ b/src/buildtool/execution_api/common/common_api.cpp
@@ -108,15 +108,21 @@ auto CommonUploadBlobTree(BlobTreePtr const& blob_tree,
return false;
}
}
- // Store blob.
- try {
- container.Emplace(node->Blob());
- } catch (...) {
+ // Optimize store & upload by taking into account the maximum
+ // transfer size.
+ if (not UpdateContainerAndUpload<ArtifactDigest>(
+ &container,
+ std::move(node->Blob()),
+ /*exception_is_fatal=*/false,
+ [&api](ArtifactBlobContainer&& blobs) -> bool {
+ return api->Upload(std::move(blobs),
+ /*skip_find_missing=*/true);
+ })) {
return false;
}
}
}
-
+ // Transfer any remaining blobs.
return api->Upload(std::move(container), /*skip_find_missing=*/true);
}
@@ -126,10 +132,18 @@ auto CommonUploadTreeCompatible(
BazelMsgFactory::LinkDigestResolveFunc const& resolve_links) noexcept
-> std::optional<ArtifactDigest> {
ArtifactBlobContainer blobs{};
+ // Store and upload blobs, taking into account the maximum transfer size.
auto digest = BazelMsgFactory::CreateDirectoryDigestFromTree(
- build_root, resolve_links, [&blobs](BazelBlob&& blob) {
- blobs.Emplace(ArtifactBlob{
- ArtifactDigest{blob.digest}, blob.data, blob.is_exec});
+ build_root, resolve_links, [&blobs, &api](BazelBlob&& blob) {
+ return UpdateContainerAndUpload<ArtifactDigest>(
+ &blobs,
+ std::move(ArtifactBlob{
+ ArtifactDigest{blob.digest}, blob.data, blob.is_exec}),
+ /*exception_is_fatal=*/false,
+ [&api](ArtifactBlobContainer&& container) -> bool {
+ return api->Upload(std::move(container),
+ /*skip_find_missing=*/false);
+ });
});
if (not digest) {
Logger::Log(LogLevel::Debug, "failed to create digest for build root.");
@@ -141,6 +155,7 @@ auto CommonUploadTreeCompatible(
oss << fmt::format(" - root digest: {}", digest->hash()) << std::endl;
return oss.str();
});
+ // Upload remaining blobs.
if (not api->Upload(std::move(blobs), /*skip_find_missing=*/false)) {
Logger::Log(LogLevel::Debug, "failed to upload blobs for build root.");
return std::nullopt;
diff --git a/src/buildtool/execution_api/git/TARGETS b/src/buildtool/execution_api/git/TARGETS
index f0895c4b..df3dfcdc 100644
--- a/src/buildtool/execution_api/git/TARGETS
+++ b/src/buildtool/execution_api/git/TARGETS
@@ -4,6 +4,7 @@
, "hdrs": ["git_api.hpp"]
, "deps":
[ ["@", "gsl", "", "gsl"]
+ , ["src/buildtool/common", "common"]
, ["src/buildtool/common", "config"]
, ["src/buildtool/execution_api/bazel_msg", "bazel_msg_factory"]
, ["src/buildtool/execution_api/common", "common"]
diff --git a/src/buildtool/execution_api/git/git_api.hpp b/src/buildtool/execution_api/git/git_api.hpp
index 914d4c19..b3b4daa3 100644
--- a/src/buildtool/execution_api/git/git_api.hpp
+++ b/src/buildtool/execution_api/git/git_api.hpp
@@ -23,8 +23,10 @@
#include <vector>
#include "gsl/gsl"
+#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp"
+#include "src/buildtool/execution_api/common/artifact_blob_container.hpp"
#include "src/buildtool/execution_api/common/common_api.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/logging/log_level.hpp"
@@ -220,25 +222,28 @@ class GitApi final : public IExecutionApi {
}
}
else {
- content = entry->RawData();
- if (not content) {
+ auto const& entry_content = entry->RawData();
+ if (not entry_content) {
return false;
}
- auto digest =
- ArtifactDigest::Create<ObjectType::File>(*content);
- try {
- tree_deps_only_blobs.Emplace(ArtifactBlob{
- digest,
- *content,
- IsExecutableObject(entry->Type())});
- } catch (std::exception const& ex) {
- Logger::Log(LogLevel::Error,
- "failed to emplace blob: ",
- ex.what());
+ auto digest = ArtifactDigest::Create<ObjectType::File>(
+ *entry_content);
+ // Collect blob and upload to remote CAS if transfer
+ // size reached.
+ if (not UpdateContainerAndUpload<ArtifactDigest>(
+ &tree_deps_only_blobs,
+ ArtifactBlob{std::move(digest),
+ *entry_content,
+ IsExecutableObject(entry->Type())},
+ /*exception_is_fatal=*/true,
+ [&api](ArtifactBlobContainer&& blobs) -> bool {
+ return api->Upload(std::move(blobs));
+ })) {
return false;
}
}
}
+ // Upload remaining blobs.
if (not api->Upload(std::move(tree_deps_only_blobs))) {
return false;
}
@@ -256,18 +261,22 @@ class GitApi final : public IExecutionApi {
? ArtifactDigest::Create<ObjectType::Tree>(*content)
: ArtifactDigest::Create<ObjectType::File>(*content);
- try {
- container.Emplace(ArtifactBlob{std::move(digest),
- *content,
- IsExecutableObject(info.type)});
- } catch (std::exception const& ex) {
- Logger::Log(
- LogLevel::Error, "failed to emplace blob: ", ex.what());
+ // Collect blob and upload to remote CAS if transfer size reached.
+ if (not UpdateContainerAndUpload<ArtifactDigest>(
+ &container,
+ ArtifactBlob{std::move(digest),
+ std::move(*content),
+ IsExecutableObject(info.type)},
+ /*exception_is_fatal=*/true,
+ [&api](ArtifactBlobContainer&& blobs) {
+ return api->Upload(std::move(blobs),
+ /*skip_find_missing=*/true);
+ })) {
return false;
}
}
- // Upload blobs to remote CAS.
+ // Upload remaining blobs to remote CAS.
return api->Upload(std::move(container), /*skip_find_missing=*/true);
}
diff --git a/src/buildtool/execution_api/local/TARGETS b/src/buildtool/execution_api/local/TARGETS
index 294311e7..f29e0c3a 100644
--- a/src/buildtool/execution_api/local/TARGETS
+++ b/src/buildtool/execution_api/local/TARGETS
@@ -30,6 +30,7 @@
[ ["@", "fmt", "", "fmt"]
, ["@", "gsl", "", "gsl"]
, ["@", "grpc", "", "grpc++"]
+ , ["src/buildtool/common", "common"]
, ["src/buildtool/common", "config"]
, ["src/buildtool/storage", "storage"]
, ["src/buildtool/execution_api/common", "common"]
@@ -49,7 +50,6 @@
[ ["src/buildtool/file_system", "object_type"]
, ["src/buildtool/system", "system_command"]
, "config"
- , ["src/buildtool/common", "common"]
, ["src/buildtool/common", "bazel_types"]
, ["src/buildtool/file_system", "file_system_manager"]
, ["src/buildtool/execution_api/utils", "outputscheck"]
diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp
index d8f0481d..75ad97bc 100644
--- a/src/buildtool/execution_api/local/local_api.hpp
+++ b/src/buildtool/execution_api/local/local_api.hpp
@@ -30,10 +30,12 @@
#include "fmt/core.h"
#include "grpcpp/support/status.h"
#include "gsl/gsl"
+#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
#include "src/buildtool/compatibility/native_support.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp"
+#include "src/buildtool/execution_api/common/artifact_blob_container.hpp"
#include "src/buildtool/execution_api/common/blob_tree.hpp"
#include "src/buildtool/execution_api/common/common_api.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
@@ -227,19 +229,22 @@ class LocalApi final : public IExecutionApi {
? ArtifactDigest::Create<ObjectType::Tree>(*content)
: ArtifactDigest::Create<ObjectType::File>(*content);
- // Collect blob.
- try {
- container.Emplace(ArtifactBlob{std::move(digest),
- *content,
- IsExecutableObject(info.type)});
- } catch (std::exception const& ex) {
- Logger::Log(
- LogLevel::Error, "failed to emplace blob: ", ex.what());
+ // Collect blob and upload to remote CAS if transfer size reached.
+ if (not UpdateContainerAndUpload<ArtifactDigest>(
+ &container,
+ ArtifactBlob{std::move(digest),
+ *content,
+ IsExecutableObject(info.type)},
+ /*exception_is_fatal=*/true,
+ [&api](ArtifactBlobContainer&& blobs) {
+ return api->Upload(std::move(blobs),
+ /*skip_find_missing=*/true);
+ })) {
return false;
}
}
- // Upload blobs to remote CAS.
+ // Upload remaining blobs to remote CAS.
return api->Upload(std::move(container), /*skip_find_missing=*/true);
}
diff --git a/src/buildtool/execution_api/remote/TARGETS b/src/buildtool/execution_api/remote/TARGETS
index 661df625..f38990ac 100644
--- a/src/buildtool/execution_api/remote/TARGETS
+++ b/src/buildtool/execution_api/remote/TARGETS
@@ -47,6 +47,7 @@
, ["src/buildtool/file_system", "object_type"]
, ["src/buildtool/compatibility", "compatibility"]
, ["src/buildtool/execution_api/bazel_msg", "bazel_msg_factory"]
+ , ["src/buildtool/execution_api/common", "common_api"]
, ["src/buildtool/execution_api/utils", "outputscheck"]
, ["src/buildtool/compatibility", "compatibility"]
, ["src/buildtool/crypto", "hash_function"]
@@ -77,6 +78,7 @@
, ["@", "fmt", "", "fmt"]
, ["src/buildtool/compatibility", "compatibility"]
, ["src/buildtool/multithreading", "task_system"]
+ , ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/file_system", "file_system_manager"]
, ["src/buildtool/file_system", "object_type"]
, ["src/buildtool/logging", "log_level"]
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
index 0a48a748..2cba30be 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -29,6 +29,7 @@
#include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_common.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp"
+#include "src/buildtool/execution_api/common/artifact_blob_container.hpp"
#include "src/buildtool/execution_api/common/common_api.hpp"
#include "src/buildtool/execution_api/common/stream_dumper.hpp"
#include "src/buildtool/execution_api/common/tree_reader.hpp"
@@ -68,15 +69,19 @@ namespace {
return false;
}
for (auto const& blob : blobs) {
- try {
- auto digest = ArtifactDigest{blob.digest};
- auto exec = info_map.contains(digest)
- ? IsExecutableObject(info_map.at(digest).type)
- : false;
- container.Emplace(ArtifactBlob{digest, blob.data, exec});
- } catch (std::exception const& ex) {
- Logger::Log(
- LogLevel::Warning, "failed to emplace blob: ", ex.what());
+ auto digest = ArtifactDigest{blob.digest};
+ auto exec = info_map.contains(digest)
+ ? IsExecutableObject(info_map.at(digest).type)
+ : false;
+ // Collect blob and upload to other CAS if transfer size reached.
+ if (not UpdateContainerAndUpload<ArtifactDigest>(
+ &container,
+ ArtifactBlob{std::move(digest), blob.data, exec},
+ /*exception_is_fatal=*/true,
+ [&api](ArtifactBlobContainer&& blobs) {
+ return api->Upload(std::move(blobs),
+ /*skip_find_missing=*/true);
+ })) {
return false;
}
}
@@ -89,7 +94,7 @@ namespace {
return false;
}
- // Upload blobs to other CAS.
+ // Upload remaining blobs to other CAS.
return api->Upload(std::move(container), /*skip_find_missing=*/true);
}
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
index aea90ba8..df1d4736 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_response.cpp
@@ -18,7 +18,8 @@
#include "gsl/gsl"
#include "src/buildtool/compatibility/native_support.hpp"
-#include "src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp"
+#include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp"
+#include "src/buildtool/execution_api/common/common_api.hpp"
#include "src/buildtool/execution_api/remote/bazel/bazel_cas_client.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
@@ -219,16 +220,39 @@ auto BazelResponse::UploadTreeMessageDirectories(
return std::nullopt;
}
auto root_digest = rootdir_blob->digest;
- dir_blobs.Emplace(std::move(*rootdir_blob));
+ // store or upload rootdir blob, taking maximum transfer size into account
+ if (not UpdateContainerAndUpload<bazel_re::Digest>(
+ &dir_blobs,
+ std::move(*rootdir_blob),
+ /*exception_is_fatal=*/false,
+ [&network = network_](BazelBlobContainer&& blobs) {
+ return network->UploadBlobs(std::move(blobs));
+ })) {
+ Logger::Log(LogLevel::Error,
+ "uploading Tree's Directory messages failed");
+ return std::nullopt;
+ }
for (auto const& subdir : tree.children()) {
auto subdir_blob = ProcessDirectoryMessage(subdir);
if (not subdir_blob) {
return std::nullopt;
}
- dir_blobs.Emplace(std::move(*subdir_blob));
+ // store or upload blob, taking maximum transfer size into account
+ if (not UpdateContainerAndUpload<bazel_re::Digest>(
+ &dir_blobs,
+ std::move(*subdir_blob),
+ /*exception_is_fatal=*/false,
+ [&network = network_](BazelBlobContainer&& blobs) {
+ return network->UploadBlobs(std::move(blobs));
+ })) {
+ Logger::Log(LogLevel::Error,
+ "uploading Tree's Directory messages failed");
+ return std::nullopt;
+ }
}
+ // upload any remaining blob
if (not network_->UploadBlobs(std::move(dir_blobs))) {
Logger::Log(LogLevel::Error,
"uploading Tree's Directory messages failed");
diff --git a/src/buildtool/execution_engine/executor/TARGETS b/src/buildtool/execution_engine/executor/TARGETS
index 82171387..6855f87b 100644
--- a/src/buildtool/execution_engine/executor/TARGETS
+++ b/src/buildtool/execution_engine/executor/TARGETS
@@ -5,12 +5,14 @@
, "deps":
[ ["src/buildtool/logging", "log_level"]
, ["src/buildtool/logging", "logging"]
+ , ["src/buildtool/common", "common"]
, ["src/buildtool/common", "config"]
, ["src/buildtool/common", "tree"]
, ["src/buildtool/compatibility", "compatibility"]
, ["src/buildtool/file_system", "file_system_manager"]
, ["src/buildtool/execution_engine/dag", "dag"]
, ["src/buildtool/execution_api/common", "common"]
+ , ["src/buildtool/execution_api/common", "common_api"]
, ["src/buildtool/execution_api/remote", "config"]
, ["src/buildtool/execution_api/remote", "bazel"]
, ["src/buildtool/progress_reporting", "progress"]
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index 2f14446a..ad933a93 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -28,11 +28,14 @@
#include <vector>
#include "gsl/gsl"
+#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/common/remote/remote_common.hpp"
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/common/tree.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
+#include "src/buildtool/execution_api/common/artifact_blob_container.hpp"
+#include "src/buildtool/execution_api/common/common_api.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
@@ -303,20 +306,23 @@ class ExecutorImpl {
if (not content) {
return false;
}
- try {
- container.Emplace(
+ // store and/or upload blob, taking into account the maximum
+ // transfer size
+ if (not UpdateContainerAndUpload<ArtifactDigest>(
+ &container,
ArtifactBlob{digest,
std::move(*content),
- IsExecutableObject(entry->Type())});
- } catch (std::exception const& ex) {
- Logger::Log(LogLevel::Error,
- "failed to create blob with: ",
- ex.what());
+ IsExecutableObject(entry->Type())},
+ /*exception_is_fatal=*/true,
+ [&api](ArtifactBlobContainer&& blobs) {
+ return api->Upload(std::move(blobs),
+ /*skip_find_missing=*/true);
+ })) {
return false;
}
}
}
-
+ // upload remaining blobs
return api->Upload(std::move(container), /*skip_find_missing=*/true);
}
diff --git a/src/buildtool/graph_traverser/TARGETS b/src/buildtool/graph_traverser/TARGETS
index 23bd8e94..b160715a 100644
--- a/src/buildtool/graph_traverser/TARGETS
+++ b/src/buildtool/graph_traverser/TARGETS
@@ -4,12 +4,15 @@
, "hdrs": ["graph_traverser.hpp"]
, "deps":
[ ["src/buildtool/common", "cli"]
+ , ["src/buildtool/common", "common"]
, ["src/buildtool/common", "config"]
, ["src/buildtool/common", "tree"]
, ["src/buildtool/common/remote", "remote_common"]
, ["src/buildtool/execution_engine/dag", "dag"]
, ["src/buildtool/execution_engine/executor", "executor"]
, ["src/buildtool/execution_engine/traverser", "traverser"]
+ , ["src/buildtool/execution_api/common", "common"]
+ , ["src/buildtool/execution_api/common", "common_api"]
, ["src/buildtool/execution_api/common", "create_execution_api"]
, ["src/buildtool/execution_api/local", "local"]
, ["src/buildtool/execution_api/remote", "bazel"]
diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp
index f10f96d5..194ae6d4 100644
--- a/src/buildtool/graph_traverser/graph_traverser.hpp
+++ b/src/buildtool/graph_traverser/graph_traverser.hpp
@@ -31,12 +31,15 @@
#include "fmt/core.h"
#include "gsl/gsl"
+#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/common/cli.hpp"
#include "src/buildtool/common/remote/remote_common.hpp"
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/common/statistics.hpp"
#include "src/buildtool/common/tree.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_blob_container.hpp"
+#include "src/buildtool/execution_api/common/artifact_blob_container.hpp"
+#include "src/buildtool/execution_api/common/common_api.hpp"
#include "src/buildtool/execution_api/common/create_execution_api.hpp"
#include "src/buildtool/execution_api/local/local_api.hpp"
#include "src/buildtool/execution_api/remote/bazel/bazel_api.hpp"
@@ -332,17 +335,20 @@ class GraphTraverser {
digest.hash(),
digest.size());
});
- try {
- container.Emplace(
- ArtifactBlob{std::move(digest), blob, /*is_exec=*/false});
- } catch (std::exception const& ex) {
- Logger::Log(logger_,
- LogLevel::Error,
- "failed to create blob with: ",
- ex.what());
+ // Store and/or upload blob, taking into account the maximum
+ // transfer size.
+ if (not UpdateContainerAndUpload<ArtifactDigest>(
+ &container,
+ ArtifactBlob{std::move(digest), blob, /*is_exec=*/false},
+ /*exception_is_fatal=*/true,
+ [&api = remote_api_](ArtifactBlobContainer&& blobs) {
+ return api->Upload(std::move(blobs));
+ },
+ logger_)) {
return false;
}
}
+ // Upload remaining blobs.
return remote_api_->Upload(std::move(container));
}