Add no-remote-cache and no-remote-exec execution requirements
This resolves https://github.com/bazelbuild/bazel/issues/7932
It introduces two new execution requirements:
- `no-remote-exec`: disallows remote execution without preventing remote caching
- `no-remote-cache`: disallows remote caching without preventing remote execution or local caching
The current behavior of `no-remote` and `no-cache` remain unchanged.
Closes #8710.
PiperOrigin-RevId: 259901280
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 06f4a04..fa7b9c3 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
@@ -111,11 +111,13 @@
this.topLevelOutputs = Preconditions.checkNotNull(topLevelOutputs, "topLevelOutputs");
}
-
@Override
public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context)
throws InterruptedException, IOException, ExecException {
- if (!Spawns.mayBeCached(spawn) || !Spawns.mayBeExecutedRemotely(spawn)) {
+ if (!Spawns.mayBeCached(spawn)
+ || (!Spawns.mayBeCachedRemotely(spawn) && isRemoteCache(options))) {
+ // returning SpawnCache.NO_RESULT_NO_STORE in case the caching is disabled or in case
+ // the remote caching is disabled and the only configured cache is remote.
return SpawnCache.NO_RESULT_NO_STORE;
}
boolean checkCache = options.remoteAcceptCached;
@@ -291,4 +293,8 @@
cmdlineReporter.handle(evt);
}
}
+
+ private static boolean isRemoteCache(RemoteOptions options) {
+ return !isNullOrEmpty(options.remoteCache);
+ }
}