Skip to content

Commit d35f923

Browse files
sluongngcopybara-github
authored andcommitted
RemoteExecutionService: fix outputs not being uploaded
In 4d900ce we introduced validation in DiskAndRemoteCacheClient.uploadActionResult() where context's step must be UPLOAD_OUTPUTS to trigger the upload. However, this value was never set in RemoteExecutionService before hand thus led to outputs not being uploaded and cause remote cache misses. Fix #15682 Thanks @adam-singer for doing the investigation 🙏 Closes #15823. PiperOrigin-RevId: 459519852 Change-Id: Ib004403d7893fe135adcc4b181b607d8cb33f3af
1 parent af70488 commit d35f923

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,8 @@ public void uploadOutputs(RemoteAction action, SpawnResult spawnResult)
11961196
SpawnResult.Status.SUCCESS.equals(spawnResult.status()) && spawnResult.exitCode() == 0,
11971197
"shouldn't upload outputs of failed local action");
11981198

1199+
action.getRemoteActionExecutionContext().setStep(Step.UPLOAD_OUTPUTS);
1200+
11991201
if (remoteOptions.remoteCacheAsync) {
12001202
Single.using(
12011203
remoteCache::retain,

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

+27
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,33 @@ EOF
15831583
rm -rf $cache
15841584
}
15851585

1586+
function test_combined_cache_upload() {
1587+
mkdir -p a
1588+
echo 'bar' > a/bar
1589+
cat > a/BUILD <<'EOF'
1590+
genrule(
1591+
name = "foo",
1592+
srcs = [":bar"],
1593+
outs = ["foo.txt"],
1594+
cmd = """
1595+
echo $(location :bar) > "$@"
1596+
""",
1597+
)
1598+
EOF
1599+
1600+
CACHEDIR=$(mktemp -d)
1601+
1602+
bazel build \
1603+
--disk_cache=$CACHEDIR \
1604+
--remote_cache=grpc://localhost:${worker_port} \
1605+
//a:foo >& $TEST_log || "Failed to build //a:foo"
1606+
1607+
remote_ac_files="$(count_remote_ac_files)"
1608+
[[ "$remote_ac_files" == 1 ]] || fail "Expected 1 remote action cache entries, not $remote_ac_files"
1609+
remote_cas_files="$(count_remote_cas_files)"
1610+
[[ "$remote_cas_files" == 3 ]] || fail "Expected 3 remote cas entries, not $remote_cas_files"
1611+
}
1612+
15861613
function test_combined_cache_with_no_remote_cache_tag_remote_cache() {
15871614
# Test that actions with no-remote-cache tag can hit disk cache of a combined cache but
15881615
# remote cache is disabled.

0 commit comments

Comments
 (0)