Skip to content

Commit eaf4c77

Browse files
committed
Allow locally build actions with scrubbed inputs
1 parent 663beb6 commit eaf4c77

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ public CachePolicy getWriteCachePolicy(Spawn spawn) {
341341
public boolean mayBeExecutedRemotely(Spawn spawn) {
342342
return remoteCache instanceof RemoteExecutionCache
343343
&& remoteExecutor != null
344-
&& Spawns.mayBeExecutedRemotely(spawn);
344+
&& Spawns.mayBeExecutedRemotely(spawn)
345+
&& !hasScrubbedInput(spawn, scrubber);
345346
}
346347

347348
@VisibleForTesting
@@ -1574,6 +1575,31 @@ void report(Event evt) {
15741575
}
15751576
}
15761577

1578+
private static boolean hasScrubbedInput(Spawn spawn, @Nullable Scrubber scrubber) {
1579+
if (scrubber == null) {
1580+
return false;
1581+
}
1582+
SpawnScrubber spawnScrubber = scrubber.forSpawn(spawn);
1583+
if (spawnScrubber == null) {
1584+
return false;
1585+
}
1586+
if (!spawnScrubber.getSalt().isEmpty()) {
1587+
return true;
1588+
}
1589+
for (String arg : spawn.getArguments()) {
1590+
if (!arg.equals(spawnScrubber.transformArgument(arg))) {
1591+
return true;
1592+
}
1593+
}
1594+
var inputFiles = spawn.getInputFiles();
1595+
for (ActionInput inputFile : inputFiles.getLeaves()) {
1596+
if (spawnScrubber.shouldOmitInput(inputFile)) {
1597+
return true;
1598+
}
1599+
}
1600+
return false;
1601+
}
1602+
15771603
/**
15781604
* A simple value class combining a hash of the tool inputs (and their digests) as well as a set
15791605
* of the relative paths of all tool inputs.

src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,7 @@ public void beforeCommand(CommandEnvironment env) throws AbruptExitException {
314314

315315
boolean enableScrubbing = remoteOptions.scrubber != null;
316316
if (enableScrubbing && enableRemoteExecution) {
317-
318-
throw createOptionsExitException(
319-
"Cannot combine remote cache key scrubbing with remote execution",
320-
FailureDetails.RemoteOptions.Code.EXECUTION_WITH_SCRUBBING);
317+
env.getReporter().handle(Event.warn("Cannot combine remote cache key scrubbing with remote execution. All actions with cache key scrubbing will be executed locally"));
321318
}
322319

323320
// TODO(bazel-team): Consider adding a warning or more validation if the remoteDownloadRegex is

0 commit comments

Comments
 (0)