Do not upload artifacts from the local execution of no-cache spawns.
Previously, marking a spawn "no-cache" resulted in its outputs being uploaded but not the action result protobuf. This was confusing to many users, who want to use "no-cache" to prevent actions with large outputs from filling the cache.
Progress on #4343.
RELNOTES: Locally-executed spawns tagged "no-cache" no longer upload their outputs to the remote cache.
Closes #7231.
PiperOrigin-RevId: 230716153
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java
index c0ab03b..d941685 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java
@@ -90,7 +90,10 @@
@Override
public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context)
throws InterruptedException, IOException, ExecException {
- boolean checkCache = options.remoteAcceptCached && Spawns.mayBeCached(spawn);
+ if (!Spawns.mayBeCached(spawn)) {
+ return SpawnCache.NO_RESULT_NO_STORE;
+ }
+ boolean checkCache = options.remoteAcceptCached;
if (checkCache) {
context.report(ProgressStatus.CHECKING_CACHE, "remote-cache");
@@ -122,7 +125,7 @@
digestUtil.compute(command),
repository.getMerkleDigest(inputRoot),
context.getTimeout(),
- Spawns.mayBeCached(spawn));
+ true);
// Look up action cache, and reuse the action output if it is found.
actionKey = digestUtil.computeActionKey(action);
}
@@ -197,10 +200,7 @@
return;
}
}
- boolean uploadAction =
- Spawns.mayBeCached(spawn)
- && Status.SUCCESS.equals(result.status())
- && result.exitCode() == 0;
+ boolean uploadAction = Status.SUCCESS.equals(result.status()) && result.exitCode() == 0;
Context previous = withMetadata.attach();
Collection<Path> files =
RemoteSpawnRunner.resolveActionInputs(execRoot, spawn.getOutputFiles());