Skip to content

Commit 5f312dd

Browse files
ulfjackCopybara-Service
authored and
Copybara-Service
committed
Fix event id for action_completed BEP events
The id should be the exec path not the absolute path. Otherwise the stdout and stderr don't line up correctly. PiperOrigin-RevId: 215369211
1 parent f59fad7 commit 5f312dd

File tree

6 files changed

+15
-5
lines changed

6 files changed

+15
-5
lines changed

src/main/java/com/google/devtools/build/lib/actions/ActionExecutedEvent.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.devtools.build.lib.buildeventstream.PathConverter;
2929
import com.google.devtools.build.lib.events.ExtendedEventHandler.ProgressLike;
3030
import com.google.devtools.build.lib.vfs.Path;
31+
import com.google.devtools.build.lib.vfs.PathFragment;
3132
import java.util.Collection;
3233
import java.util.logging.Level;
3334
import java.util.logging.Logger;
@@ -39,6 +40,7 @@
3940
public class ActionExecutedEvent implements BuildEventWithConfiguration, ProgressLike {
4041
private static final Logger logger = Logger.getLogger(ActionExecutedEvent.class.getName());
4142

43+
private final PathFragment actionId;
4244
private final Action action;
4345
private final ActionExecutionException exception;
4446
private final Path primaryOutput;
@@ -47,12 +49,14 @@ public class ActionExecutedEvent implements BuildEventWithConfiguration, Progres
4749
private final ErrorTiming timing;
4850

4951
public ActionExecutedEvent(
52+
PathFragment actionId,
5053
Action action,
5154
ActionExecutionException exception,
5255
Path primaryOutput,
5356
Path stdout,
5457
Path stderr,
5558
ErrorTiming timing) {
59+
this.actionId = actionId;
5660
this.action = action;
5761
this.exception = exception;
5862
this.primaryOutput = primaryOutput;
@@ -93,10 +97,10 @@ public String getStderr() {
9397
@Override
9498
public BuildEventId getEventId() {
9599
if (action.getOwner() == null) {
96-
return BuildEventId.actionCompleted(primaryOutput);
100+
return BuildEventId.actionCompleted(actionId);
97101
} else {
98102
return BuildEventId.actionCompleted(
99-
primaryOutput,
103+
actionId,
100104
action.getOwner().getLabel(),
101105
action.getOwner().getConfigurationChecksum());
102106
}

src/main/java/com/google/devtools/build/lib/buildeventstream/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ java_library(
1919
"//src/main/java/com/google/devtools/build/lib/concurrent",
2020
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec",
2121
"//src/main/java/com/google/devtools/build/lib/vfs",
22+
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
2223
"//src/main/java/com/google/devtools/common/options",
2324
"//third_party:guava",
2425
"//third_party:jsr305",

src/main/java/com/google/devtools/build/lib/buildeventstream/BuildEventId.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.google.devtools.build.lib.causes.Cause;
2020
import com.google.devtools.build.lib.cmdline.Label;
2121
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
22-
import com.google.devtools.build.lib.vfs.Path;
22+
import com.google.devtools.build.lib.vfs.PathFragment;
2323
import com.google.protobuf.TextFormat;
2424
import java.io.Serializable;
2525
import java.util.List;
@@ -233,12 +233,12 @@ public static BuildEventId fromCause(Cause cause) {
233233
return new BuildEventId(cause.getIdProto());
234234
}
235235

236-
public static BuildEventId actionCompleted(Path path) {
236+
public static BuildEventId actionCompleted(PathFragment path) {
237237
return actionCompleted(path, null, null);
238238
}
239239

240240
public static BuildEventId actionCompleted(
241-
Path path, @Nullable Label label, @Nullable String configurationChecksum) {
241+
PathFragment path, @Nullable Label label, @Nullable String configurationChecksum) {
242242
ActionCompletedId.Builder actionId =
243243
ActionCompletedId.newBuilder().setPrimaryOutput(path.toString());
244244
if (label != null) {

src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java

+1
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,7 @@ private void reportActionExecution(
12601260
}
12611261
eventHandler.post(
12621262
new ActionExecutedEvent(
1263+
action.getPrimaryOutput().getExecPath(),
12631264
action,
12641265
exception,
12651266
actionExecutionContext.getInputPath(action.getPrimaryOutput()),

src/test/java/com/google/devtools/build/lib/buildeventservice/BazelBuildEventServiceModuleTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class BazelBuildEventServiceModuleTest {
6060

6161
private static final ActionExecutedEvent SUCCESSFUL_ACTION_EXECUTED_EVENT =
6262
new ActionExecutedEvent(
63+
ActionsTestUtil.DUMMY_ARTIFACT.getExecPath(),
6364
new ActionsTestUtil.NullAction(),
6465
/* exception= */ null,
6566
ActionsTestUtil.DUMMY_ARTIFACT.getPath(),

src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class BuildEventStreamerTest extends FoundationTestCase {
8686

8787
private static final ActionExecutedEvent SUCCESSFUL_ACTION_EXECUTED_EVENT =
8888
new ActionExecutedEvent(
89+
ActionsTestUtil.DUMMY_ARTIFACT.getExecPath(),
8990
new ActionsTestUtil.NullAction(),
9091
/* exception= */ null,
9192
ActionsTestUtil.DUMMY_ARTIFACT.getPath(),
@@ -912,6 +913,7 @@ public void testSuccessfulActionsAreNotPublishedByDefault() {
912913

913914
ActionExecutedEvent failedActionExecutedEvent =
914915
new ActionExecutedEvent(
916+
ActionsTestUtil.DUMMY_ARTIFACT.getExecPath(),
915917
new ActionsTestUtil.NullAction(),
916918
new ActionExecutionException("Exception", /* action= */ null, /* catastrophe= */ false),
917919
ActionsTestUtil.DUMMY_ARTIFACT.getPath(),
@@ -942,6 +944,7 @@ public void testSuccessfulActionsCanBePublished() {
942944

943945
ActionExecutedEvent failedActionExecutedEvent =
944946
new ActionExecutedEvent(
947+
ActionsTestUtil.DUMMY_ARTIFACT.getExecPath(),
945948
new ActionsTestUtil.NullAction(),
946949
new ActionExecutionException("Exception", /* action= */ null, /* catastrophe= */ false),
947950
ActionsTestUtil.DUMMY_ARTIFACT.getPath(),

0 commit comments

Comments
 (0)