Skip to content

Commit 1a3af64

Browse files
committed
Add log for false and any-match scrubbing rule
1 parent 2ffd886 commit 1a3af64

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@
6161
import com.google.common.collect.Iterables;
6262
import com.google.common.collect.Maps;
6363
import com.google.common.eventbus.Subscribe;
64+
import com.google.common.flogger.GoogleLogger;
6465
import com.google.common.util.concurrent.Futures;
6566
import com.google.common.util.concurrent.ListenableFuture;
6667
import com.google.common.util.concurrent.SettableFuture;
6768
import com.google.devtools.build.lib.actions.ActionInput;
69+
import com.google.devtools.build.lib.actions.ActionOwner;
6870
import com.google.devtools.build.lib.actions.Artifact;
6971
import com.google.devtools.build.lib.actions.ArtifactPathResolver;
7072
import com.google.devtools.build.lib.actions.EnvironmentalExecException;
@@ -1983,7 +1985,7 @@ void report(Event evt) {
19831985
}
19841986
}
19851987

1986-
private static boolean hasScrubbedInput(Spawn spawn, @Nullable Scrubber scrubber) {
1988+
private boolean hasScrubbedInput(Spawn spawn, @Nullable Scrubber scrubber) {
19871989
if (scrubber == null) {
19881990
return false;
19891991
}
@@ -2000,11 +2002,23 @@ private static boolean hasScrubbedInput(Spawn spawn, @Nullable Scrubber scrubber
20002002
}
20012003
}
20022004
var inputFiles = spawn.getInputFiles();
2005+
2006+
String mnemonic = spawn.getMnemonic();
2007+
ActionOwner actionOwner = spawn.getResourceOwner().getOwner();
2008+
String label = actionOwner.getLabel().getCanonicalForm();
2009+
String kind = actionOwner.getTargetKind();
2010+
20032011
for (ActionInput inputFile : inputFiles.toList()) {
20042012
if (spawnScrubber.shouldOmitInput(inputFile.getExecPath())) {
2013+
if (!spawnScrubber.hasMatcher) {
2014+
reporter.handle(Event.warn(String.format("Used file-based scrubber for mnemonic: %s, label: %s, kind: %s", mnemonic, label, kind)));
2015+
}
20052016
return true;
20062017
}
20072018
}
2019+
if (spawnScrubber.hasMatcher) {
2020+
reporter.handle(Event.warn(String.format("Unused scrubber for mnemonic: %s, label: %s, kind: %s", mnemonic, label, kind)));
2021+
}
20082022
return false;
20092023
}
20102024

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public static class SpawnScrubber {
110110
private final ImmutableList<Pattern> omittedInputPatterns;
111111
private final ImmutableMap<Pattern, String> argReplacements;
112112
private final String salt;
113+
public final boolean hasMatcher;
113114

114115
private SpawnScrubber(Config.Rule ruleProto) {
115116
Config.Matcher matcherProto = ruleProto.getMatcher();
@@ -127,6 +128,7 @@ private SpawnScrubber(Config.Rule ruleProto) {
127128
transformProto.getArgReplacementsList().stream()
128129
.collect(toImmutableMap(r -> Pattern.compile(r.getSource()), r -> r.getTarget()));
129130
this.salt = ruleProto.getTransform().getSalt();
131+
this.hasMatcher = ruleProto.hasMatcher();
130132
}
131133

132134
private String emptyToAll(String s) {

0 commit comments

Comments
 (0)