Skip to content

Commit

Permalink
And mnemonic and label to remote metadata
Browse files Browse the repository at this point in the history
This reflects bazelbuild/remote-apis#186

Closes #13109.

PiperOrigin-RevId: 368763391
  • Loading branch information
illicitonion authored and copybara-github committed Apr 16, 2021
1 parent 04632e5 commit a750a56
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,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 @@ -188,7 +188,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 @@ -154,7 +154,7 @@ private Completable downloadFileAsync(Path path, FileArtifactValue metadata) {
() -> {
RequestMetadata requestMetadata =
TracingMetadataUtils.buildMetadata(
buildRequestId, commandId, metadata.getActionId());
buildRequestId, commandId, metadata.getActionId(), null);
RemoteActionExecutionContext context =
RemoteActionExecutionContext.create(requestMetadata);

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 @@ -257,7 +257,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 @@ -17,6 +17,7 @@
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.remote.options.RemoteOptions;
import io.grpc.ClientInterceptor;
Expand Down Expand Up @@ -46,19 +47,28 @@ 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()
.setCorrelatedInvocationsId(buildRequestId)
.setToolInvocationId(commandId)
.setActionId(actionId)
.setToolDetails(
ToolDetails.newBuilder()
.setToolName("bazel")
.setToolVersion(BlazeVersionInfo.instance().getVersion()))
.build();
RequestMetadata.Builder builder =
RequestMetadata.newBuilder()
.setCorrelatedInvocationsId(buildRequestId)
.setToolInvocationId(commandId)
.setActionId(actionId)
.setToolDetails(
ToolDetails.newBuilder()
.setToolName("bazel")
.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,8 @@ 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,8 @@ 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 a750a56

Please sign in to comment.