From ad6f4da7b6f55be55ac2b3c2294deebbb20c1f83 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Mon, 1 Mar 2021 15:17:20 +0000 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. --- .../build/lib/remote/RemoteRepositoryRemoteExecutor.java | 2 +- .../google/devtools/build/lib/remote/RemoteSpawnCache.java | 2 +- .../google/devtools/build/lib/remote/RemoteSpawnRunner.java | 5 +++-- 3 files changed, 5 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 a69cc904c179d4..29f89d47cff5fd 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 @@ -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); 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 41be210f56cf34..6c73f973a82782 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 @@ -242,7 +242,7 @@ 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()); @@ -695,9 +695,10 @@ 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.setPlatform(platform); action.setCommandDigest(command); action.setInputRootDigest(inputRoot); if (!timeout.isZero()) {