Skip to content

Commit

Permalink
Remote: Add remoteCacheable key to execution log
Browse files Browse the repository at this point in the history
Fixes #13495.

Closes #13551.

PiperOrigin-RevId: 378090621
  • Loading branch information
coeuvre authored and copybara-github committed Jun 8, 2021
1 parent 149882a commit 0c07c2e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,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());
Expand Down
3 changes: 3 additions & 0 deletions src/main/protobuf/spawn.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ public void testLogSpawn() throws Exception {
.setExitCode(23)
.setRemotable(true)
.setCacheable(true)
.setRemoteCacheable(true)
.setProgressMessage("my progress message")
.setMnemonic("MyMnemonic")
.setRunner("runner")
Expand Down Expand Up @@ -486,6 +487,7 @@ private static SpawnExec.Builder defaultSpawnExecBuilder(String cmd) {
.setMnemonic("Mnemonic")
.setRunner("runner")
.setStatus("NON_ZERO_EXIT")
.setExitCode(23);
.setExitCode(23)
.setRemoteCacheable(true);
}
}
13 changes: 13 additions & 0 deletions src/test/shell/bazel/bazel_execlog_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,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"

0 comments on commit 0c07c2e

Please sign in to comment.