diff options
author | 2016-12-12 23:20:37 +0000 | |
---|---|---|
committer | 2016-12-13 16:30:29 +0000 | |
commit | fb9d52cd397e857d020cc5e8ca5ea0a6220f144f (patch) | |
tree | 8cc7cdb70eba737b1ac03d116ae221c846fdeb04 | |
parent | 1c44aa656027fdb0013678d0242f5b8eb941a512 (diff) |
Add a flag for disabling local fallback for actions that failed remotely.
--
PiperOrigin-RevId: 141817345
MOS_MIGRATED_REVID=141817345
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java | 8 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java | 16 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java index 538c5544aa..53fb4a967d 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java @@ -114,4 +114,12 @@ public final class RemoteOptions extends OptionsBase { help = "Whether to accept remotely cached action results." ) public boolean remoteAcceptCached; + + @Option( + name = "remote_allow_local_fallback", + defaultValue = "true", + category = "remote", + help = "Whether to fall back to standalone strategy if remote fails." + ) + public boolean remoteAllowLocalFallback; } diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java index 4dc998e7f8..14a275e819 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java @@ -67,6 +67,7 @@ final class RemoteSpawnStrategy implements SpawnActionContext { private final RemoteWorkExecutor remoteWorkExecutor; private final boolean verboseFailures; private final boolean remoteAcceptCached; + private final boolean remoteAllowLocalFallback; RemoteSpawnStrategy( Map<String, String> clientEnv, @@ -82,6 +83,7 @@ final class RemoteSpawnStrategy implements SpawnActionContext { this.remoteActionCache = actionCache; this.remoteWorkExecutor = workExecutor; this.remoteAcceptCached = options.remoteAcceptCached; + this.remoteAllowLocalFallback = options.remoteAllowLocalFallback; } private Action buildAction( @@ -239,7 +241,7 @@ final class RemoteSpawnStrategy implements SpawnActionContext { remoteActionCache.downloadAllResults(result, execRoot); return; } - if (status.getError() == ExecutionStatus.ErrorCode.EXEC_FAILED) { + if (status.getError() == ExecutionStatus.ErrorCode.EXEC_FAILED || !remoteAllowLocalFallback) { passRemoteOutErr(result, actionExecutionContext.getFileOutErr()); throw new UserExecException(status.getErrorDetail()); } @@ -258,10 +260,18 @@ final class RemoteSpawnStrategy implements SpawnActionContext { stackTrace = "\n" + Throwables.getStackTraceAsString(e); } eventHandler.handle(Event.warn(mnemonic + " remote work failed (" + e + ")" + stackTrace)); - execLocally(spawn, actionExecutionContext, actionKey); + if (remoteAllowLocalFallback) { + execLocally(spawn, actionExecutionContext, actionKey); + } else { + throw new UserExecException(e); + } } catch (CacheNotFoundException e) { eventHandler.handle(Event.warn(mnemonic + " remote work results cache miss (" + e + ")")); - execLocally(spawn, actionExecutionContext, actionKey); + if (remoteAllowLocalFallback) { + execLocally(spawn, actionExecutionContext, actionKey); + } else { + throw new UserExecException(e); + } } catch (UnsupportedOperationException e) { eventHandler.handle( Event.warn(mnemonic + " unsupported operation for action cache (" + e + ")")); |