From 82ef52e4d4d8720ae88050ee09bb6cd88f71ccbb 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 +- .../devtools/build/lib/remote/RemoteSpawnRunner.java | 7 +++++-- 3 files changed, 7 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..eb9c32b1291320 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,7 +695,7 @@ 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); @@ -706,6 +706,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(); }