diff --git a/src/main/java/com/google/devtools/build/lib/remote/BUILD b/src/main/java/com/google/devtools/build/lib/remote/BUILD index 39d0ce2cfabff1..d20cf2b67749ea 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/BUILD +++ b/src/main/java/com/google/devtools/build/lib/remote/BUILD @@ -126,8 +126,8 @@ java_library( "//src/main/java/com/google/devtools/build/skyframe", "//src/main/java/com/google/devtools/build/skyframe:skyframe-objects", "//src/main/java/com/google/devtools/common/options", + "//src/main/protobuf:cache_salt_java_proto", "//src/main/protobuf:failure_details_java_proto", - "//src/main/protobuf:spawn_java_proto", "//third_party:auth", "//third_party:caffeine", "//third_party:flogger", diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java index 8f15ad60ca1773..c3d612d5441ad2 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java @@ -77,7 +77,6 @@ import com.google.devtools.build.lib.buildtool.buildevent.BuildInterruptedEvent; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.Reporter; -import com.google.devtools.build.lib.exec.Protos.CacheSalt; import com.google.devtools.build.lib.exec.SpawnInputExpander.InputWalker; import com.google.devtools.build.lib.exec.SpawnRunner.SpawnExecutionContext; import com.google.devtools.build.lib.exec.local.LocalEnvProvider; @@ -100,6 +99,7 @@ import com.google.devtools.build.lib.remote.common.RemotePathResolver; import com.google.devtools.build.lib.remote.merkletree.MerkleTree; import com.google.devtools.build.lib.remote.options.RemoteOptions; +import com.google.devtools.build.lib.remote.salt.CacheSalt; import com.google.devtools.build.lib.remote.util.DigestUtil; import com.google.devtools.build.lib.remote.util.TempPathGenerator; import com.google.devtools.build.lib.remote.util.TracingMetadataUtils; diff --git a/src/main/protobuf/BUILD b/src/main/protobuf/BUILD index 1440c3eabe98f4..abb19a3d6ef848 100644 --- a/src/main/protobuf/BUILD +++ b/src/main/protobuf/BUILD @@ -221,6 +221,21 @@ java_library_srcs( deps = [":remote_execution_log_java_proto"], ) +proto_library( + name = "cache_salt_proto", + srcs = ["cache_salt.proto"], +) + +java_proto_library( + name = "cache_salt_java_proto", + deps = [":cache_salt_proto"], +) + +java_library_srcs( + name = "cache_salt_java_proto_srcs", + deps = [":cache_salt_java_proto"], +) + proto_library( name = "remote_scrubbing_proto", srcs = ["remote_scrubbing.proto"], @@ -284,6 +299,7 @@ filegroup( name = "dist_jars", srcs = [s + "_java_proto_srcs" for s in FILES] + [ ":analysis_v2_java_proto_srcs", + ":cache_salt_java_proto_srcs", ":command_line_java_proto_srcs", ":command_server_java_grpc_srcs", ":command_server_java_proto_srcs", diff --git a/src/main/protobuf/cache_salt.proto b/src/main/protobuf/cache_salt.proto new file mode 100644 index 00000000000000..a614194a7641a0 --- /dev/null +++ b/src/main/protobuf/cache_salt.proto @@ -0,0 +1,43 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package tools.protos; + +option java_package = "com.google.devtools.build.lib.remote.salt"; +option java_multiple_files = true; + +// Additional information that should be taken into account when computing the +// disk or remote cache key for a spawn, thereby ensuring that spawns remain +// distinct. +message CacheSalt { + // Whether or not the spawn may be executed remotely, if remote + // execution were to be enabled. This ensures that adding/removing the + // "no-remote-exec" tag from a target forces a local/remote rebuild. + bool may_be_executed_remotely = 1; + + // Requires the execution service do NOT share caches across different + // workspaces. + string workspace = 2; + + message ScrubSalt { + // A unique value used to bust the cache for scrubbed spawns. + string salt = 1; + } + + // Ensures that a scrubbed spawn can never collide with a non-scrubbed one. + // See the documentation for the --experimental_remote_scrub_config flag. + ScrubSalt scrub_salt = 3; +} diff --git a/src/main/protobuf/spawn.proto b/src/main/protobuf/spawn.proto index 028e7b1abe9d2c..970ccb5172e5a5 100644 --- a/src/main/protobuf/spawn.proto +++ b/src/main/protobuf/spawn.proto @@ -192,26 +192,3 @@ message SpawnExec { // Timing, size and memory statistics. SpawnMetrics metrics = 20; } - -// Additional information that should be taken into account when -// computing the key of an action, thereby ensuring that actions remain -// distinct. -message CacheSalt { - // Whether or not the action may be executed remotely, if remote - // execution were to be enabled. This ensures that adding/removing the - // "no-remote-exec" tag from a target forces a local/remote rebuild. - bool may_be_executed_remotely = 1; - - // Requires the execution service do NOT share caches across different - // workspace. - string workspace = 2; - - message ScrubSalt { - // A unique value used to bust the cache for scrubbed actions. - string salt = 1; - } - - // Ensures that a scrubbed action can never collide with a non-scrubbed one. - // See the documentation for the --experimental_remote_scrub_config flag. - ScrubSalt scrub_salt = 3; -} diff --git a/src/test/java/com/google/devtools/build/lib/remote/BUILD b/src/test/java/com/google/devtools/build/lib/remote/BUILD index d0191278b30d06..ae348943a481de 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/BUILD +++ b/src/test/java/com/google/devtools/build/lib/remote/BUILD @@ -117,6 +117,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/vfs/bazel", "//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs", "//src/main/java/com/google/devtools/common/options", + "//src/main/protobuf:cache_salt_java_proto", "//src/main/protobuf:failure_details_java_proto", "//src/main/protobuf:remote_scrubbing_java_proto", "//src/main/protobuf:spawn_java_proto", diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java index bf2a5f3f9ea61b..146fb7bf6ba1c1 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteExecutionServiceTest.java @@ -83,7 +83,6 @@ import com.google.devtools.build.lib.events.EventKind; import com.google.devtools.build.lib.events.Reporter; import com.google.devtools.build.lib.events.StoredEventHandler; -import com.google.devtools.build.lib.exec.Protos.CacheSalt; import com.google.devtools.build.lib.exec.util.FakeOwner; import com.google.devtools.build.lib.exec.util.SpawnBuilder; import com.google.devtools.build.lib.remote.RemoteExecutionService.RemoteActionResult; @@ -97,6 +96,7 @@ import com.google.devtools.build.lib.remote.common.RemotePathResolver.SiblingRepositoryLayoutResolver; import com.google.devtools.build.lib.remote.merkletree.MerkleTree; import com.google.devtools.build.lib.remote.options.RemoteOptions; +import com.google.devtools.build.lib.remote.salt.CacheSalt; import com.google.devtools.build.lib.remote.util.DigestUtil; import com.google.devtools.build.lib.remote.util.FakeSpawnExecutionContext; import com.google.devtools.build.lib.remote.util.InMemoryCacheClient;