Skip to content

Commit

Permalink
Allow locally build actions with scrubbed inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
bozaro committed Nov 8, 2023
1 parent 2cb3159 commit 9e9af91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ public CachePolicy getWriteCachePolicy(Spawn spawn) {
public boolean mayBeExecutedRemotely(Spawn spawn) {
return remoteCache instanceof RemoteExecutionCache
&& remoteExecutor != null
&& Spawns.mayBeExecutedRemotely(spawn);
&& Spawns.mayBeExecutedRemotely(spawn)
&& !hasScrubbedInput(spawn, scrubber);
}

@VisibleForTesting
Expand Down Expand Up @@ -1595,6 +1596,23 @@ void report(Event evt) {
}
}

private static boolean hasScrubbedInput(Spawn spawn, @Nullable Scrubber scrubber) {
if (scrubber == null) {
return false;
}
SpawnScrubber spawnScrubber = scrubber.forSpawn(spawn);
if (spawnScrubber == null) {
return false;
}
var inputFiles = spawn.getInputFiles();
for (ActionInput inputFile : inputFiles.getLeaves()) {
if (spawnScrubber.shouldOmitInput(inputFile)) {
return true;
}
}
return false;
}

/**
* A simple value class combining a hash of the tool inputs (and their digests) as well as a set
* of the relative paths of all tool inputs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,7 @@ public void beforeCommand(CommandEnvironment env) throws AbruptExitException {

boolean enableScrubbing = remoteOptions.scrubber != null;
if (enableScrubbing && enableRemoteExecution) {

throw createOptionsExitException(
"Cannot combine remote cache key scrubbing with remote execution",
FailureDetails.RemoteOptions.Code.EXECUTION_WITH_SCRUBBING);
env.getReporter().handle(Event.warn("Cannot combine remote cache key scrubbing with remote execution. All actions with cache key scrubbing will be executed locally"));
}

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

0 comments on commit 9e9af91

Please sign in to comment.