Skip to content

Commit

Permalink
And mnemonic and label to remote metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Mar 1, 2021
1 parent e044d2e commit 0e05f38
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static List<PathMetadata> processQueryResult(
private ListenableFuture<ImmutableIterable<PathMetadata>> queryRemoteCache(
ImmutableList<ListenableFuture<PathMetadata>> allPaths) throws Exception {
RequestMetadata metadata =
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, "bes-upload");
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, "bes-upload", null);
RemoteActionExecutionContext context = RemoteActionExecutionContext.create(metadata);

List<PathMetadata> knownRemotePaths = new ArrayList<>(allPaths.size());
Expand Down Expand Up @@ -195,7 +195,7 @@ private ListenableFuture<ImmutableIterable<PathMetadata>> queryRemoteCache(
private ListenableFuture<List<PathMetadata>> uploadLocalFiles(
ImmutableIterable<PathMetadata> allPaths) {
RequestMetadata metadata =
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, "bes-upload");
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, "bes-upload", null);
RemoteActionExecutionContext context = RemoteActionExecutionContext.create(metadata);

ImmutableList.Builder<ListenableFuture<PathMetadata>> allPathsUploaded =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private ListenableFuture<Void> downloadFileAsync(Path path, FileArtifactValue me
ListenableFuture<Void> download = downloadsInProgress.get(path);
if (download == null) {
RequestMetadata requestMetadata =
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, metadata.getActionId());
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, metadata.getActionId(), null);
RemoteActionExecutionContext context = RemoteActionExecutionContext.create(requestMetadata);

Digest digest = DigestUtil.buildDigest(metadata.getDigest(), metadata.getSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public ExecutionResult execute(
Duration timeout)
throws IOException, InterruptedException {
RequestMetadata metadata =
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, "repository_rule");
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, "repository_rule", null);
RemoteActionExecutionContext context = RemoteActionExecutionContext.create(metadata);

Platform platform = PlatformUtils.buildPlatformProto(executionProperties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private CapabilitiesBlockingStub capabilitiesBlockingStub(RemoteActionExecutionC
public ServerCapabilities get(String buildRequestId, String commandId)
throws IOException, InterruptedException {
RequestMetadata metadata =
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, "capabilities");
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, "capabilities", null);
RemoteActionExecutionContext context = RemoteActionExecutionContext.create(metadata);
try {
GetCapabilitiesRequest request =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context)

RequestMetadata metadata =
TracingMetadataUtils.buildMetadata(
buildRequestId, commandId, actionKey.getDigest().getHash());
buildRequestId, commandId, actionKey.getDigest().getHash(), spawn.getResourceOwner());
RemoteActionExecutionContext remoteActionExecutionContext =
RemoteActionExecutionContext.create(metadata);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)

RequestMetadata metadata =
TracingMetadataUtils.buildMetadata(
buildRequestId, commandId, actionKey.getDigest().getHash());
buildRequestId, commandId, actionKey.getDigest().getHash(), spawn.getResourceOwner());
RemoteActionExecutionContext remoteActionExecutionContext =
RemoteActionExecutionContext.create(metadata);
Profiler prof = Profiler.instance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void download(
com.google.common.base.Optional<String> type)
throws IOException, InterruptedException {
RequestMetadata metadata =
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, "remote_downloader");
TracingMetadataUtils.buildMetadata(buildRequestId, commandId, "remote_downloader", null);
RemoteActionExecutionContext remoteActionExecutionContext =
RemoteActionExecutionContext.create(metadata);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/actions:execution_requirements",
"//src/main/java/com/google/devtools/build/lib/analysis:blaze_version_info",
"//src/main/java/com/google/devtools/build/lib/authandtls",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/concurrent",
"//src/main/java/com/google/devtools/build/lib/remote:ExecutionStatusException",
"//src/main/java/com/google/devtools/build/lib/remote/common",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import build.bazel.remote.execution.v2.ToolDetails;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.devtools.build.lib.actions.ActionExecutionMetadata;
import com.google.devtools.build.lib.analysis.BlazeVersionInfo;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.remote.options.RemoteOptions;
import io.grpc.ClientInterceptor;
import io.grpc.Context;
Expand Down Expand Up @@ -46,19 +48,24 @@ private TracingMetadataUtils() {}
ProtoUtils.keyForProto(RequestMetadata.getDefaultInstance());

public static RequestMetadata buildMetadata(
String buildRequestId, String commandId, String actionId) {
String buildRequestId, String commandId, String actionId, @Nullable ActionExecutionMetadata actionMetadata) {
Preconditions.checkNotNull(buildRequestId);
Preconditions.checkNotNull(commandId);
Preconditions.checkNotNull(actionId);
return RequestMetadata.newBuilder()
RequestMetadata.Builder builder = RequestMetadata.newBuilder()
.setCorrelatedInvocationsId(buildRequestId)
.setToolInvocationId(commandId)
.setActionId(actionId)
.setToolDetails(
ToolDetails.newBuilder()
.setToolName("bazel")
.setToolVersion(BlazeVersionInfo.instance().getVersion()))
.build();
.setToolVersion(BlazeVersionInfo.instance().getVersion()));
if (actionMetadata != null) {
builder.setActionMnemonic(actionMetadata.getMnemonic());
builder.setTargetId(actionMetadata.getOwner().getLabel().getCanonicalForm());
builder.setConfigurationId(actionMetadata.getOwner().getConfigurationChecksum());
}
return builder.build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public int maxConcurrency() {
TracingMetadataUtils.buildMetadata(
"none",
"none",
DIGEST_UTIL.asActionKey(Digest.getDefaultInstance()).getDigest().getHash());
DIGEST_UTIL.asActionKey(Digest.getDefaultInstance()).getDigest().getHash(),
null);
context = RemoteActionExecutionContext.create(metadata);

retryService = MoreExecutors.listeningDecorator(Executors.newScheduledThreadPool(1));
Expand Down Expand Up @@ -679,7 +680,8 @@ public void queryWriteStatus(
TracingMetadataUtils.buildMetadata(
"build-req-id",
"command-id",
DIGEST_UTIL.asActionKey(actionDigest).getDigest().getHash());
DIGEST_UTIL.asActionKey(actionDigest).getDigest().getHash(),
null);
RemoteActionExecutionContext remoteActionExecutionContext =
RemoteActionExecutionContext.create(metadata);
uploads.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public final void setUp() throws Exception {
FileSystemUtils.createDirectoryAndParents(stderr.getParentDirectory());
outErr = new FileOutErr(stdout, stderr);
RequestMetadata metadata =
TracingMetadataUtils.buildMetadata("none", "none", Digest.getDefaultInstance().getHash());
TracingMetadataUtils.buildMetadata("none", "none", Digest.getDefaultInstance().getHash(), null);
context = RemoteActionExecutionContext.create(metadata);
retryService = MoreExecutors.listeningDecorator(Executors.newScheduledThreadPool(1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public class RemoteCacheTests {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
RequestMetadata metadata =
TracingMetadataUtils.buildMetadata("none", "none", Digest.getDefaultInstance().getHash());
TracingMetadataUtils.buildMetadata("none", "none", Digest.getDefaultInstance().getHash(), null);
context = RemoteActionExecutionContext.create(metadata);
fs = new InMemoryFileSystem(new JavaClock(), DigestHashFunction.SHA256);
execRoot = fs.getPath("/execroot/main");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public final void setUp() throws Exception {
TracingMetadataUtils.buildMetadata(
"none",
"none",
DIGEST_UTIL.asActionKey(Digest.getDefaultInstance()).getDigest().getHash());
DIGEST_UTIL.asActionKey(Digest.getDefaultInstance()).getDigest().getHash(),
null);
context = RemoteActionExecutionContext.create(metadata);

retryService = MoreExecutors.listeningDecorator(Executors.newScheduledThreadPool(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public void setUp() throws Exception {
remoteActionExecutionContext =
RemoteActionExecutionContext.create(
TracingMetadataUtils.buildMetadata(
"none", "none", Digest.getDefaultInstance().getHash()));
"none", "none", Digest.getDefaultInstance().getHash(), null));
}

@Test
Expand Down

0 comments on commit 0e05f38

Please sign in to comment.