Skip to content

Commit bb8e6ec

Browse files
fmeumcopybara-github
authored andcommitted
Match execroot relative path with --experimental_remote_download_regex
Previously, the regex was applied to the full on-disk path of an output, which can lead to non-hermetic matching behavior. Closes #16474. PiperOrigin-RevId: 481187240 Change-Id: I96b6777c71baaab80cac629542400e3f77b59caf
1 parent f499e04 commit bb8e6ec

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,8 @@ private ImmutableList<ListenableFuture<FileMetadata>> buildFilesToDownloadWithPr
12281228
ImmutableList.Builder<ListenableFuture<FileMetadata>> builder = new ImmutableList.Builder<>();
12291229

12301230
for (FileMetadata file : metadata.files()) {
1231-
if (!realToTmpPath.containsKey(file.path) && predicate.test(file.path.toString())) {
1231+
if (!realToTmpPath.containsKey(file.path)
1232+
&& predicate.test(file.path.relativeTo(execRoot).toString())) {
12321233
Path tmpPath = tempPathGenerator.generateTempPath();
12331234
realToTmpPath.put(file.path, tmpPath);
12341235
builder.add(downloadFile(context, progressStatusListener, file, tmpPath));
@@ -1237,7 +1238,8 @@ private ImmutableList<ListenableFuture<FileMetadata>> buildFilesToDownloadWithPr
12371238

12381239
for (Map.Entry<Path, DirectoryMetadata> entry : metadata.directories()) {
12391240
for (FileMetadata file : entry.getValue().files()) {
1240-
if (!realToTmpPath.containsKey(file.path) && predicate.test(file.path.toString())) {
1241+
if (!realToTmpPath.containsKey(file.path)
1242+
&& predicate.test(file.path.relativeTo(execRoot).toString())) {
12411243
Path tmpPath = tempPathGenerator.generateTempPath();
12421244
realToTmpPath.put(file.path, tmpPath);
12431245
builder.add(downloadFile(context, progressStatusListener, file, tmpPath));

src/test/shell/bazel/remote/build_without_the_bytes_test.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,18 @@ EOF
12281228
[[ ! -e "bazel-bin/a/liblib.jar" ]] || fail "bazel-bin/a/liblib.jar shouldn't exist"
12291229
[[ ! -e "bazel-bin/a/liblib.jdeps" ]] || fail "bazel-bin/a/liblib.jdeps shouldn't exist"
12301230

1231+
# io_bazel is the name of the Bazel workspace and thus contained in the full
1232+
# path of any output artifact, but not in the exec root relative part that we
1233+
# want the regex to match against.
1234+
bazel clean && bazel test \
1235+
--remote_executor=grpc://localhost:${worker_port} \
1236+
--remote_download_minimal \
1237+
--experimental_remote_download_regex="/io_bazel/" \
1238+
//a:test >& $TEST_log || fail "Failed to build"
1239+
1240+
[[ ! -e "bazel-bin/a/liblib.jar" ]] || fail "bazel-bin/a/liblib.jar file shouldn't exist!"
1241+
[[ ! -e "bazel-bin/a/liblib.jdeps" ]] || fail "bazel-bin/a/liblib.jdeps file shouldn't exist!"
1242+
12311243
bazel clean && bazel test \
12321244
--remote_executor=grpc://localhost:${worker_port} \
12331245
--remote_download_minimal \

0 commit comments

Comments
 (0)