Skip to content

Commit

Permalink
Update remote execution api to preliminary version v2.3
Browse files Browse the repository at this point in the history
In preparation for the introduction of our blob splitting protocol as extension
to the remote execution api, we need to update the used remote execution api to
a more recent version than v2.0.0. Since no new tags are available right now,
we update to the preliminary protocol version v2.3 according to the following
discussion: bazelbuild/remote-apis#253
  • Loading branch information
roloffs committed Jun 28, 2023
1 parent 3f864ea commit 21481c7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
10 changes: 5 additions & 5 deletions etc/repos.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@
, "bazel_remote_apis":
{ "repository":
{ "type": "archive"
, "content": "b5deb95d544f03f1918cc9d611c7904b8173befa"
, "fetch": "https://github.com/bazelbuild/remote-apis/archive/v2.0.0.tar.gz"
, "sha256": "79204ed1fa385c03b5235f65b25ced6ac51cf4b00e45e1157beca6a28bdb8043"
, "sha512": "7465f4726a9cc263352f6f0ec5b065c53e2ad787611740e1a458331858bdf28d53d69ba3db3d83fbf4a578229a413ac230886b5fcd33ab76425c61b1f08ef3b3"
, "subdir": "remote-apis-2.0.0"
, "content": "da6d7d589ccd1924ba9840a4e329e438dfa27f86"
, "fetch": "https://github.com/bazelbuild/remote-apis/archive/e1fe21be4c9ae76269a5a63215bb3c72ed9ab3f0.tar.gz"
, "sha256": "7421abd5352ccf927c2050453a4dbfa1f7b1c7170ec3e8702b6fe2d39b8805fe"
, "sha512": "3042690ee4b17a27db92ca867b4225c25f3f16344dce5fe86695d72ddda531e1593a5f0f70a291283451ce1e9f606c2285d222df3787815cd8f4054e1113bc9d"
, "subdir": "remote-apis-e1fe21be4c9ae76269a5a63215bb3c72ed9ab3f0"
}
, "target_root": "import targets"
, "target_file_name": "TARGETS.bazel_remote_apis"
Expand Down
31 changes: 20 additions & 11 deletions src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,10 @@ template <class T>
copy_nodes(dir.mutable_directories(), dirs);
copy_nodes(dir.mutable_symlinks(), links);

std::copy(props.cbegin(),
props.cend(),
pb::back_inserter(dir.mutable_node_properties()));
std::copy(
props.cbegin(),
props.cend(),
pb::back_inserter(dir.mutable_node_properties()->mutable_properties()));

return dir;
}
Expand All @@ -229,7 +230,8 @@ template <class T>
node.set_is_executable(IsExecutableObject(type));
std::copy(props.cbegin(),
props.cend(),
pb::back_inserter(node.mutable_node_properties()));
pb::back_inserter(
node.mutable_node_properties()->mutable_properties()));
return node;
}

Expand All @@ -252,7 +254,8 @@ template <class T>
node.set_target(target);
std::copy(props.cbegin(),
props.cend(),
pb::back_inserter(node.mutable_node_properties()));
pb::back_inserter(
node.mutable_node_properties()->mutable_properties()));
return node;
}

Expand Down Expand Up @@ -322,6 +325,10 @@ template <class T>
std::vector<bazel_re::Platform_Property> const& platform_properties)
-> CommandBundle::Ptr {
bazel_re::Command msg;
// DEPRECATED as of v2.2: platform properties are now specified
// directly in the action. See documentation note in the
// [Action][build.bazel.remote.execution.v2.Action] for migration.
// (https://github.com/bazelbuild/remote-apis/blob/e1fe21be4c9ae76269a5a63215bb3c72ed9ab3f0/build/bazel/remote/execution/v2/remote_execution.proto#L646)
msg.set_allocated_platform(CreatePlatform(platform_properties).release());
std::copy(std::cbegin(args),
std::cend(args),
Expand Down Expand Up @@ -349,7 +356,7 @@ template <class T>
[[nodiscard]] auto CreateActionBundle(
bazel_re::Digest const& command,
bazel_re::Digest const& root_dir,
std::vector<std::string> const& output_node_properties,
std::vector<bazel_re::Platform_Property> const& platform_properties,
bool do_not_cache,
std::chrono::milliseconds const& timeout) -> ActionBundle::Ptr {
using seconds = std::chrono::seconds;
Expand All @@ -368,9 +375,12 @@ template <class T>
gsl::owner<bazel_re::Digest*>{new bazel_re::Digest{command}});
msg.set_allocated_input_root_digest(
gsl::owner<bazel_re::Digest*>{new bazel_re::Digest{root_dir}});
std::copy(output_node_properties.cbegin(),
output_node_properties.cend(),
pb::back_inserter(msg.mutable_output_node_properties()));
// New in version 2.2: clients SHOULD set these platform properties
// as well as those in the
// [Command][build.bazel.remote.execution.v2.Command]. Servers
// SHOULD prefer those set here.
// (https://github.com/bazelbuild/remote-apis/blob/e1fe21be4c9ae76269a5a63215bb3c72ed9ab3f0/build/bazel/remote/execution/v2/remote_execution.proto#L516)
msg.set_allocated_platform(CreatePlatform(platform_properties).release());

auto content_creator = [&msg] { return SerializeMessage(msg); };

Expand Down Expand Up @@ -728,7 +738,6 @@ auto BazelMsgFactory::CreateActionDigestFromCommandLine(
bazel_re::Digest const& exec_dir,
std::vector<std::string> const& output_files,
std::vector<std::string> const& output_dirs,
std::vector<std::string> const& output_node_properties,
std::vector<bazel_re::Command_EnvironmentVariable> const& env_vars,
std::vector<bazel_re::Platform_Property> const& properties,
bool do_not_cache,
Expand All @@ -740,7 +749,7 @@ auto BazelMsgFactory::CreateActionDigestFromCommandLine(

// create action
auto action = CreateActionBundle(
cmd->Digest(), exec_dir, output_node_properties, do_not_cache, timeout);
cmd->Digest(), exec_dir, properties, do_not_cache, timeout);

if (store_blob) {
(*store_blob)(cmd->MakeBlob(/*is_exec=*/false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class BazelMsgFactory {
bazel_re::Digest const& exec_dir,
std::vector<std::string> const& output_files,
std::vector<std::string> const& output_dirs,
std::vector<std::string> const& output_node_properties,
std::vector<bazel_re::Command_EnvironmentVariable> const& env_vars,
std::vector<bazel_re::Platform_Property> const& properties,
bool do_not_cache,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ auto CapabilitiesServiceImpl::GetCapabilities(
::bazel_re::CacheCapabilities cache;
::bazel_re::ExecutionCapabilities exec;

cache.add_digest_function(
cache.add_digest_functions(
::bazel_re::DigestFunction_Value::DigestFunction_Value_SHA256);
cache.mutable_action_cache_update_capabilities()->set_update_enabled(false);
static constexpr std::size_t kMaxBatchTransferSize = 1024 * 1024;
Expand Down
1 change: 0 additions & 1 deletion src/buildtool/execution_api/local/local_action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class LocalAction final : public IExecutionAction {
exec_dir,
output_files_,
output_dirs_,
{} /*FIXME output node properties*/,
BazelMsgFactory::CreateMessageVectorFromMap<
bazel_re::Command_EnvironmentVariable>(env_vars_),
properties_,
Expand Down
1 change: 0 additions & 1 deletion src/buildtool/execution_api/remote/bazel/bazel_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ auto BazelAction::CreateBundlesForAction(BlobContainer* blobs,
exec_dir,
output_files_,
output_dirs_,
{} /*FIXME output node properties*/,
env_vars_,
properties_,
do_not_cache,
Expand Down

0 comments on commit 21481c7

Please sign in to comment.