Skip to content

Commit 32442b1

Browse files
committed
Include invocation ID in compact execution log
This makes it possible to retroactively link an execution log file to a particular build. Closes bazelbuild#24790. PiperOrigin-RevId: 715017597 Change-Id: Ia8f6a3677a165a9f428b59ab8a19587a357b8803
1 parent a6941a6 commit 32442b1

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ private void initOutputs(CommandEnvironment env) throws IOException {
111111
.experimentalSiblingRepositoryLayout,
112112
env.getOptions().getOptions(RemoteOptions.class),
113113
env.getRuntime().getFileSystem().getDigestFunction(),
114-
env.getXattrProvider());
114+
env.getXattrProvider(),
115+
env.getCommandId());
115116
} catch (InterruptedException e) {
116117
env.getReporter()
117118
.handle(Event.error("Error while setting up the execution log: " + e.getMessage()));

src/main/java/com/google/devtools/build/lib/exec/CompactSpawnLogContext.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import java.util.Comparator;
6464
import java.util.List;
6565
import java.util.SortedMap;
66+
import java.util.UUID;
6667
import java.util.concurrent.ForkJoinPool;
6768
import javax.annotation.Nullable;
6869
import javax.annotation.concurrent.GuardedBy;
@@ -143,6 +144,7 @@ private interface ExecLogEntrySupplier {
143144
@Nullable private final RemoteOptions remoteOptions;
144145
private final DigestHashFunction digestHashFunction;
145146
private final XattrProvider xattrProvider;
147+
private final UUID invocationId;
146148

147149
// Maps a key identifying an entry into its ID.
148150
// Each key is either a NestedSet.Node or the String path of a file, directory, symlink or
@@ -166,14 +168,16 @@ public CompactSpawnLogContext(
166168
boolean siblingRepositoryLayout,
167169
@Nullable RemoteOptions remoteOptions,
168170
DigestHashFunction digestHashFunction,
169-
XattrProvider xattrProvider)
171+
XattrProvider xattrProvider,
172+
UUID invocationId)
170173
throws IOException, InterruptedException {
171174
this.execRoot = execRoot;
172175
this.workspaceName = workspaceName;
173176
this.siblingRepositoryLayout = siblingRepositoryLayout;
174177
this.remoteOptions = remoteOptions;
175178
this.digestHashFunction = digestHashFunction;
176179
this.xattrProvider = xattrProvider;
180+
this.invocationId = invocationId;
177181
this.outputStream = getOutputStream(outputPath);
178182

179183
logInvocation();
@@ -194,7 +198,8 @@ private void logInvocation() throws IOException, InterruptedException {
194198
ExecLogEntry.Invocation.newBuilder()
195199
.setHashFunctionName(digestHashFunction.toString())
196200
.setWorkspaceRunfilesDirectory(workspaceName)
197-
.setSiblingRepositoryLayout(siblingRepositoryLayout)));
201+
.setSiblingRepositoryLayout(siblingRepositoryLayout)
202+
.setId(invocationId.toString())));
198203
}
199204

200205
@Override

src/main/protobuf/spawn.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ message ExecLogEntry {
232232

233233
// Whether --experimental_sibling_repository_layout is enabled.
234234
bool sibling_repository_layout = 3;
235+
236+
// The ID of the invocation.
237+
string id = 4;
235238
}
236239

237240
// An input or output file.

src/test/java/com/google/devtools/build/lib/exec/CompactSpawnLogContextTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import java.io.IOException;
4848
import java.io.InputStream;
4949
import java.util.ArrayList;
50+
import java.util.UUID;
5051
import net.starlark.java.syntax.Location;
5152
import org.junit.Test;
5253
import org.junit.runner.RunWith;
@@ -144,7 +145,8 @@ public void testSymlinkAction() throws IOException, InterruptedException {
144145
Protos.ExecLogEntry.Invocation.newBuilder()
145146
.setHashFunctionName("SHA-256")
146147
.setWorkspaceRunfilesDirectory(TestConstants.WORKSPACE_NAME)
147-
.setSiblingRepositoryLayout(siblingRepositoryLayout))
148+
.setSiblingRepositoryLayout(siblingRepositoryLayout)
149+
.setId("00000000-0000-0000-0000-000000000000"))
148150
.build(),
149151
Protos.ExecLogEntry.newBuilder()
150152
.setSymlinkAction(
@@ -244,7 +246,8 @@ protected SpawnLogContext createSpawnLogContext(ImmutableMap<String, String> pla
244246
siblingRepositoryLayout,
245247
remoteOptions,
246248
DigestHashFunction.SHA256,
247-
SyscallCache.NO_CACHE);
249+
SyscallCache.NO_CACHE,
250+
UUID.fromString("00000000-0000-0000-0000-000000000000"));
248251
}
249252

250253
@Override

0 commit comments

Comments
 (0)