diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java index e5116f09406805..9e38e09b2d1418 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java @@ -135,6 +135,7 @@ public void logSpawn( builder.setTimeoutMillis(timeout.toMillis()); } builder.setCacheable(Spawns.mayBeCached(spawn)); + builder.setRemoteCacheable(Spawns.mayBeCachedRemotely(spawn)); builder.setExitCode(result.exitCode()); builder.setRemoteCacheHit(result.isCacheHit()); builder.setRunner(result.getRunnerName()); diff --git a/src/main/protobuf/spawn.proto b/src/main/protobuf/spawn.proto index f602fe625ed515..7fb621a13df9dd 100644 --- a/src/main/protobuf/spawn.proto +++ b/src/main/protobuf/spawn.proto @@ -123,4 +123,7 @@ message SpawnExec { // Its semantics varies greatly depending on the status field. // Dependable: if status is empty, exit_code is guaranteed to be zero. int32 exit_code = 15; + + // Was the Spawn result allowed to be cached remotely. + bool remote_cacheable = 16; } diff --git a/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java b/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java index 389b5ec2460203..a2bd3f467bd983 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java +++ b/src/test/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategyTest.java @@ -363,6 +363,7 @@ public void testLogSpawn() throws Exception { .setExitCode(23) .setRemotable(true) .setCacheable(true) + .setRemoteCacheable(true) .setProgressMessage("my progress message") .setMnemonic("MyMnemonic") .setRunner("runner") @@ -489,6 +490,7 @@ private static SpawnExec.Builder defaultSpawnExecBuilder(String cmd) { .setMnemonic("Mnemonic") .setRunner("runner") .setStatus("NON_ZERO_EXIT") - .setExitCode(23); + .setExitCode(23) + .setRemoteCacheable(true); } } diff --git a/src/test/shell/bazel/bazel_execlog_test.sh b/src/test/shell/bazel/bazel_execlog_test.sh index 11412e0687a463..be4dd234bc25dc 100755 --- a/src/test/shell/bazel/bazel_execlog_test.sh +++ b/src/test/shell/bazel/bazel_execlog_test.sh @@ -168,4 +168,17 @@ EOF grep "listedOutputs" output.json || fail "log does not contain listed outputs" } +function test_no_remote_cache() { + cat > BUILD <<'EOF' +genrule( + name = "action", + outs = ["out.txt"], + cmd = "echo hello > $(location out.txt)", + tags = ["no-remote-cache"], +) +EOF + bazel build //:action --execution_log_json_file=output.json 2>&1 >> $TEST_log || fail "could not build" + grep "\"remoteCacheable\": false" output.json || fail "log does not contain valid remoteCacheable entry" +} + run_suite "execlog_tests"