Skip to content

Commit 82452c7

Browse files
sgowrojicoeuvre
andauthored
Fix an issue that `incompatible_remote_build_event_upload_respect_no_… (bazelbuild#16045)
* Fix an issue that `incompatible_remote_build_event_upload_respect_no_… …cache` doesn't work with BwtB. The root cause is we use `Path` as key to check which files are omitted, but it also compares the underlying filesystem. When BwtB is enabled, the filesystem for the file is different so we failed to mark the file as omitted. This change fixes that by using `PathFragment` as key. Fixes bazelbuild#15527. Closes bazelbuild#16023. PiperOrigin-RevId: 465284879 Change-Id: I49bbd7a6055e0f234b4ac86a224886bd85797f71 * Update ByteStreamBuildEventArtifactUploader changes Removing the import as it is throwing the error Co-authored-by: Chi Wang <[email protected]>
1 parent 9d57003 commit 82452c7

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

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

+9-7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.google.devtools.build.lib.remote.util.DigestUtil;
3535
import com.google.devtools.build.lib.remote.util.TracingMetadataUtils;
3636
import com.google.devtools.build.lib.vfs.Path;
37+
import com.google.devtools.build.lib.vfs.PathFragment;
3738
import io.netty.util.AbstractReferenceCounted;
3839
import io.netty.util.ReferenceCounted;
3940
import io.reactivex.rxjava3.core.Flowable;
@@ -67,8 +68,8 @@ class ByteStreamBuildEventArtifactUploader extends AbstractReferenceCounted
6768
private final AtomicBoolean shutdown = new AtomicBoolean();
6869
private final Scheduler scheduler;
6970

70-
private final Set<Path> omittedFiles = Sets.newConcurrentHashSet();
71-
private final Set<Path> omittedTreeRoots = Sets.newConcurrentHashSet();
71+
private final Set<PathFragment> omittedFiles = Sets.newConcurrentHashSet();
72+
private final Set<PathFragment> omittedTreeRoots = Sets.newConcurrentHashSet();
7273

7374
ByteStreamBuildEventArtifactUploader(
7475
Executor executor,
@@ -89,11 +90,11 @@ class ByteStreamBuildEventArtifactUploader extends AbstractReferenceCounted
8990
}
9091

9192
public void omitFile(Path file) {
92-
omittedFiles.add(file);
93+
omittedFiles.add(file.asFragment());
9394
}
9495

9596
public void omitTree(Path treeRoot) {
96-
omittedTreeRoots.add(treeRoot);
97+
omittedTreeRoots.add(treeRoot.asFragment());
9798
}
9899

99100
/** 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 {
153154
/* omitted= */ false);
154155
}
155156

157+
PathFragment filePathFragment = file.asFragment();
156158
boolean omitted = false;
157-
if (omittedFiles.contains(file)) {
159+
if (omittedFiles.contains(filePathFragment)) {
158160
omitted = true;
159161
} else {
160-
for (Path treeRoot : omittedTreeRoots) {
162+
for (PathFragment treeRoot : omittedTreeRoots) {
161163
if (file.startsWith(treeRoot)) {
162-
omittedFiles.add(file);
164+
omittedFiles.add(filePathFragment);
163165
omitted = true;
164166
}
165167
}

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

+23
Original file line numberDiff line numberDiff line change
@@ -3536,6 +3536,29 @@ EOF
35363536
expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data"
35373537
}
35383538

3539+
function test_uploader_respect_no_cache_minimal() {
3540+
mkdir -p a
3541+
cat > a/BUILD <<EOF
3542+
genrule(
3543+
name = 'foo',
3544+
outs = ["foo.txt"],
3545+
cmd = "echo \"foo bar\" > \$@",
3546+
tags = ["no-cache"],
3547+
)
3548+
EOF
3549+
3550+
bazel build \
3551+
--remote_cache=grpc://localhost:${worker_port} \
3552+
--remote_download_minimal \
3553+
--incompatible_remote_build_event_upload_respect_no_cache \
3554+
--build_event_json_file=bep.json \
3555+
//a:foo >& $TEST_log || fail "Failed to build"
3556+
3557+
cat bep.json > $TEST_log
3558+
expect_not_log "a:foo.*bytestream://" || fail "local files are converted"
3559+
expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data"
3560+
}
3561+
35393562
function test_uploader_alias_action_respect_no_cache() {
35403563
mkdir -p a
35413564
cat > a/BUILD <<EOF

0 commit comments

Comments
 (0)