Skip to content

Commit 0c07c2e

Browse files
coeuvrecopybara-github
authored andcommitted
Remote: Add remoteCacheable key to execution log
Fixes #13495. Closes #13551. PiperOrigin-RevId: 378090621
1 parent 149882a commit 0c07c2e

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public void logSpawn(
138138
builder.setTimeoutMillis(timeout.toMillis());
139139
}
140140
builder.setCacheable(Spawns.mayBeCached(spawn));
141+
builder.setRemoteCacheable(Spawns.mayBeCachedRemotely(spawn));
141142
builder.setExitCode(result.exitCode());
142143
builder.setRemoteCacheHit(result.isCacheHit());
143144
builder.setRunner(result.getRunnerName());

src/main/protobuf/spawn.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,7 @@ message SpawnExec {
123123
// Its semantics varies greatly depending on the status field.
124124
// Dependable: if status is empty, exit_code is guaranteed to be zero.
125125
int32 exit_code = 15;
126+
127+
// Was the Spawn result allowed to be cached remotely.
128+
bool remote_cacheable = 16;
126129
}

src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ public void testLogSpawn() throws Exception {
360360
.setExitCode(23)
361361
.setRemotable(true)
362362
.setCacheable(true)
363+
.setRemoteCacheable(true)
363364
.setProgressMessage("my progress message")
364365
.setMnemonic("MyMnemonic")
365366
.setRunner("runner")
@@ -486,6 +487,7 @@ private static SpawnExec.Builder defaultSpawnExecBuilder(String cmd) {
486487
.setMnemonic("Mnemonic")
487488
.setRunner("runner")
488489
.setStatus("NON_ZERO_EXIT")
489-
.setExitCode(23);
490+
.setExitCode(23)
491+
.setRemoteCacheable(true);
490492
}
491493
}

src/test/shell/bazel/bazel_execlog_test.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,17 @@ EOF
188188
grep "listedOutputs" output.json || fail "log does not contain listed outputs"
189189
}
190190

191+
function test_no_remote_cache() {
192+
cat > BUILD <<'EOF'
193+
genrule(
194+
name = "action",
195+
outs = ["out.txt"],
196+
cmd = "echo hello > $(location out.txt)",
197+
tags = ["no-remote-cache"],
198+
)
199+
EOF
200+
bazel build //:action --execution_log_json_file=output.json 2>&1 >> $TEST_log || fail "could not build"
201+
grep "\"remoteCacheable\": false" output.json || fail "log does not contain valid remoteCacheable entry"
202+
}
203+
191204
run_suite "execlog_tests"

0 commit comments

Comments
 (0)