Skip to content

Commit dad9630

Browse files
illicitonioncopybara-github
authored andcommitted
Set Platform on Action not just Command
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 #13134. PiperOrigin-RevId: 360647520
1 parent ce7afe7 commit dad9630

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/main/java/com/google/devtools/build/lib/remote/RemoteRepositoryRemoteExecutor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public ExecutionResult execute(
117117
MerkleTree merkleTree = MerkleTree.build(inputFiles, digestUtil);
118118
Action action =
119119
RemoteSpawnRunner.buildAction(
120-
commandHash, merkleTree.getRootDigest(), timeout, acceptCached);
120+
commandHash, merkleTree.getRootDigest(), platform, timeout, acceptCached);
121121
Digest actionDigest = digestUtil.compute(action);
122122
ActionKey actionKey = new ActionKey(actionDigest);
123123
ActionResult actionResult;

src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context)
148148
RemoteOutputsMode remoteOutputsMode = options.remoteOutputsMode;
149149
Action action =
150150
RemoteSpawnRunner.buildAction(
151-
digestUtil.compute(command), merkleTreeRoot, context.getTimeout(), true);
151+
digestUtil.compute(command), merkleTreeRoot, platform, context.getTimeout(), true);
152152
// Look up action cache, and reuse the action output if it is found.
153153
ActionKey actionKey = digestUtil.computeActionKey(action);
154154

src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)
242242
Digest commandHash = digestUtil.compute(command);
243243
Action action =
244244
buildAction(
245-
commandHash, merkleTree.getRootDigest(), context.getTimeout(), spawnCacheableRemotely);
245+
commandHash,
246+
merkleTree.getRootDigest(),
247+
platform,
248+
context.getTimeout(),
249+
spawnCacheableRemotely);
246250

247251
spawnMetrics.setParseTime(totalTime.elapsed());
248252

@@ -695,7 +699,12 @@ private SpawnResult handleError(
695699
.build();
696700
}
697701

698-
static Action buildAction(Digest command, Digest inputRoot, Duration timeout, boolean cacheable) {
702+
static Action buildAction(
703+
Digest command,
704+
Digest inputRoot,
705+
@Nullable Platform platform,
706+
Duration timeout,
707+
boolean cacheable) {
699708

700709
Action.Builder action = Action.newBuilder();
701710
action.setCommandDigest(command);
@@ -706,6 +715,9 @@ static Action buildAction(Digest command, Digest inputRoot, Duration timeout, bo
706715
if (!cacheable) {
707716
action.setDoNotCache(true);
708717
}
718+
if (platform != null) {
719+
action.setPlatform(platform);
720+
}
709721
return action.build();
710722
}
711723

0 commit comments

Comments
 (0)