From 9563215226058af3d441252b5181a9d453410476 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 3 Mar 2021 05:31:49 -0800 Subject: [PATCH] Set Platform on Action not just Command https://github.com/bazelbuild/remote-apis/pull/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 --- .../remote/RemoteRepositoryRemoteExecutor.java | 2 +- .../build/lib/remote/RemoteSpawnCache.java | 2 +- .../build/lib/remote/RemoteSpawnRunner.java | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteRepositoryRemoteExecutor.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteRepositoryRemoteExecutor.java index a74c42f653e866..ba8331f612aff6 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteRepositoryRemoteExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteRepositoryRemoteExecutor.java @@ -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; diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java index ba70436abc89a8..00581e34a583f3 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java @@ -147,7 +147,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); diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java index 49777032608b57..e1976b6f8a9a0b 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java @@ -235,7 +235,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()); @@ -688,7 +692,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); @@ -699,6 +708,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(); }