diff --git a/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java b/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java index 0e3b79cedf070f..15c12bbb1b093e 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java +++ b/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java @@ -34,6 +34,7 @@ import com.google.devtools.build.lib.remote.util.DigestUtil; import com.google.devtools.build.lib.remote.util.TracingMetadataUtils; import com.google.devtools.build.lib.vfs.Path; +import com.google.devtools.build.lib.vfs.PathFragment; import io.netty.util.AbstractReferenceCounted; import io.netty.util.ReferenceCounted; import io.reactivex.rxjava3.core.Flowable; @@ -67,8 +68,8 @@ class ByteStreamBuildEventArtifactUploader extends AbstractReferenceCounted private final AtomicBoolean shutdown = new AtomicBoolean(); private final Scheduler scheduler; - private final Set omittedFiles = Sets.newConcurrentHashSet(); - private final Set omittedTreeRoots = Sets.newConcurrentHashSet(); + private final Set omittedFiles = Sets.newConcurrentHashSet(); + private final Set omittedTreeRoots = Sets.newConcurrentHashSet(); ByteStreamBuildEventArtifactUploader( Executor executor, @@ -89,11 +90,11 @@ class ByteStreamBuildEventArtifactUploader extends AbstractReferenceCounted } public void omitFile(Path file) { - omittedFiles.add(file); + omittedFiles.add(file.asFragment()); } public void omitTree(Path treeRoot) { - omittedTreeRoots.add(treeRoot); + omittedTreeRoots.add(treeRoot.asFragment()); } /** Returns {@code true} if Bazel knows that the file is stored on a remote system. */ @@ -153,13 +154,14 @@ private PathMetadata readPathMetadata(Path file) throws IOException { /* omitted= */ false); } + PathFragment filePathFragment = file.asFragment(); boolean omitted = false; - if (omittedFiles.contains(file)) { + if (omittedFiles.contains(filePathFragment)) { omitted = true; } else { - for (Path treeRoot : omittedTreeRoots) { + for (PathFragment treeRoot : omittedTreeRoots) { if (file.startsWith(treeRoot)) { - omittedFiles.add(file); + omittedFiles.add(filePathFragment); omitted = true; } } diff --git a/src/test/shell/bazel/remote/remote_execution_test.sh b/src/test/shell/bazel/remote/remote_execution_test.sh index f45f93dbb2f361..e79b2dfe4f4d49 100755 --- a/src/test/shell/bazel/remote/remote_execution_test.sh +++ b/src/test/shell/bazel/remote/remote_execution_test.sh @@ -3536,6 +3536,29 @@ EOF expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data" } +function test_uploader_respect_no_cache_minimal() { + mkdir -p a + cat > a/BUILD < \$@", + tags = ["no-cache"], +) +EOF + + bazel build \ + --remote_cache=grpc://localhost:${worker_port} \ + --remote_download_minimal \ + --incompatible_remote_build_event_upload_respect_no_cache \ + --build_event_json_file=bep.json \ + //a:foo >& $TEST_log || fail "Failed to build" + + cat bep.json > $TEST_log + expect_not_log "a:foo.*bytestream://" || fail "local files are converted" + expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data" +} + function test_uploader_alias_action_respect_no_cache() { mkdir -p a cat > a/BUILD <