Skip to content

Commit cc8a56e

Browse files
committed
Remote: Make --incompatible_remote_build_event_upload_respect_no_cache working with --incompatible_remote_results_ignore_disk.
Fixes #14463. Closes #14468. PiperOrigin-RevId: 417984062
1 parent b50f2c6 commit cc8a56e

3 files changed

Lines changed: 40 additions & 16 deletions

File tree

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -356,19 +356,6 @@ public boolean shouldAcceptCachedResult(Spawn spawn) {
356356
}
357357
}
358358

359-
public static boolean shouldUploadLocalResults(
360-
RemoteOptions remoteOptions, @Nullable Map<String, String> executionInfo) {
361-
if (useRemoteCache(remoteOptions)) {
362-
if (useDiskCache(remoteOptions)) {
363-
return shouldUploadLocalResultsToCombinedDisk(remoteOptions, executionInfo);
364-
} else {
365-
return shouldUploadLocalResultsToRemoteCache(remoteOptions, executionInfo);
366-
}
367-
} else {
368-
return shouldUploadLocalResultsToDiskCache(remoteOptions, executionInfo);
369-
}
370-
}
371-
372359
/**
373360
* Returns {@code true} if the local results of the {@code spawn} should be uploaded to remote
374361
* cache.
@@ -378,7 +365,15 @@ public boolean shouldUploadLocalResults(Spawn spawn) {
378365
return false;
379366
}
380367

381-
return shouldUploadLocalResults(remoteOptions, spawn.getExecutionInfo());
368+
if (useRemoteCache(remoteOptions)) {
369+
if (useDiskCache(remoteOptions)) {
370+
return shouldUploadLocalResultsToCombinedDisk(remoteOptions, spawn);
371+
} else {
372+
return shouldUploadLocalResultsToRemoteCache(remoteOptions, spawn);
373+
}
374+
} else {
375+
return shouldUploadLocalResultsToDiskCache(remoteOptions, spawn);
376+
}
382377
}
383378

384379
/** Returns {@code true} if the spawn may be executed remotely. */

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,7 @@ private void parseNoCacheOutputs(AnalysisResult analysisResult) {
761761
RuleConfiguredTarget ruleConfiguredTarget = (RuleConfiguredTarget) configuredTarget;
762762
for (ActionAnalysisMetadata action : ruleConfiguredTarget.getActions()) {
763763
boolean uploadLocalResults =
764-
RemoteExecutionService.shouldUploadLocalResults(
765-
remoteOptions, action.getExecutionInfo());
764+
Utils.shouldUploadLocalResultsToRemoteCache(remoteOptions, action.getExecutionInfo());
766765
if (!uploadLocalResults) {
767766
for (Artifact output : action.getOutputs()) {
768767
if (output.isTreeArtifact()) {

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3469,4 +3469,34 @@ EOF
34693469
[[ "$disk_cas_files" == 0 ]] || fail "Expected 0 disk cas entries, not $disk_cas_files"
34703470
}
34713471

3472+
function test_uploader_incompatible_remote_results_ignore_disk() {
3473+
mkdir -p a
3474+
cat > a/BUILD <<EOF
3475+
genrule(
3476+
name = 'foo',
3477+
outs = ["foo.txt"],
3478+
cmd = "echo \"foo bar\" > \$@",
3479+
tags = ["no-remote"],
3480+
)
3481+
EOF
3482+
3483+
cache_dir=$(mktemp -d)
3484+
3485+
bazel build \
3486+
--remote_cache=grpc://localhost:${worker_port} \
3487+
--disk_cache=$cache_dir \
3488+
--incompatible_remote_build_event_upload_respect_no_cache \
3489+
--incompatible_remote_results_ignore_disk \
3490+
--build_event_json_file=bep.json \
3491+
//a:foo >& $TEST_log || fail "Failed to build"
3492+
3493+
cat bep.json > $TEST_log
3494+
expect_not_log "a:foo.*bytestream://" || fail "local files are converted"
3495+
expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data"
3496+
3497+
disk_cas_files="$(count_disk_cas_files $cache_dir)"
3498+
# foo.txt, stdout and stderr for action 'foo'
3499+
[[ "$disk_cas_files" == 3 ]] || fail "Expected 3 disk cas entries, not $disk_cas_files"
3500+
}
3501+
34723502
run_suite "Remote execution and remote cache tests"

0 commit comments

Comments
 (0)