Skip to content

Commit

Permalink
Set Platform on Action not just Command
Browse files Browse the repository at this point in the history
bazelbuild/remote-apis#167 promoted the field,
but left the old one present for legacy fallback for remote execution
platforms which haven't updated yet.

This PR sets both.

Closes bazelbuild#13134.

PiperOrigin-RevId: 360647520
  • Loading branch information
illicitonion authored and copybara-github committed Mar 3, 2021
1 parent ce7afe7 commit dad9630
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public ExecutionResult execute(
MerkleTree merkleTree = MerkleTree.build(inputFiles, digestUtil);
Action action =
RemoteSpawnRunner.buildAction(
commandHash, merkleTree.getRootDigest(), timeout, acceptCached);
commandHash, merkleTree.getRootDigest(), platform, timeout, acceptCached);
Digest actionDigest = digestUtil.compute(action);
ActionKey actionKey = new ActionKey(actionDigest);
ActionResult actionResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context)
RemoteOutputsMode remoteOutputsMode = options.remoteOutputsMode;
Action action =
RemoteSpawnRunner.buildAction(
digestUtil.compute(command), merkleTreeRoot, context.getTimeout(), true);
digestUtil.compute(command), merkleTreeRoot, platform, context.getTimeout(), true);
// Look up action cache, and reuse the action output if it is found.
ActionKey actionKey = digestUtil.computeActionKey(action);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)
Digest commandHash = digestUtil.compute(command);
Action action =
buildAction(
commandHash, merkleTree.getRootDigest(), context.getTimeout(), spawnCacheableRemotely);
commandHash,
merkleTree.getRootDigest(),
platform,
context.getTimeout(),
spawnCacheableRemotely);

spawnMetrics.setParseTime(totalTime.elapsed());

Expand Down Expand Up @@ -695,7 +699,12 @@ private SpawnResult handleError(
.build();
}

static Action buildAction(Digest command, Digest inputRoot, Duration timeout, boolean cacheable) {
static Action buildAction(
Digest command,
Digest inputRoot,
@Nullable Platform platform,
Duration timeout,
boolean cacheable) {

Action.Builder action = Action.newBuilder();
action.setCommandDigest(command);
Expand All @@ -706,6 +715,9 @@ static Action buildAction(Digest command, Digest inputRoot, Duration timeout, bo
if (!cacheable) {
action.setDoNotCache(true);
}
if (platform != null) {
action.setPlatform(platform);
}
return action.build();
}

Expand Down

0 comments on commit dad9630

Please sign in to comment.