Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remote: small refactoring that splits download and spawn result #7792

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,8 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)
acceptCachedResult = false;
} else {
try (SilentCloseable c = Profiler.instance().profile("Remote.downloadRemoteResults")) {
return downloadRemoteResults(cachedResult, context.getFileOutErr())
.setCacheHit(true)
.setRunnerName("remote cache hit")
.build();
remoteCache.download(cachedResult, execRoot, context.getFileOutErr());
return createSpawnResult(cachedResult.getExitCode(), /* cacheHit= */ true);
} catch (CacheNotFoundException e) {
// No cache hit, so we fall through to local or remote execution.
// We set acceptCachedResult to false in order to force the action re-execution.
Expand Down Expand Up @@ -251,7 +249,8 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)

FileOutErr outErr = context.getFileOutErr();
String message = reply.getMessage();
if ((reply.getResult().getExitCode() != 0
ActionResult actionResult = reply.getResult();
if ((actionResult.getExitCode() != 0
|| reply.getStatus().getCode() != Code.OK.value())
&& !message.isEmpty()) {
outErr.printErr(message + "\n");
Expand All @@ -264,11 +263,9 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)

try (SilentCloseable c =
Profiler.instance().profile("Remote.downloadRemoteResults")) {
return downloadRemoteResults(reply.getResult(), outErr)
.setRunnerName(reply.getCachedResult() ? "remote cache hit" : getName())
.setCacheHit(reply.getCachedResult())
.build();
remoteCache.download(actionResult, execRoot, outErr);
}
return createSpawnResult(actionResult.getExitCode(), reply.getCachedResult());
});
} catch (IOException e) {
return execLocallyAndUploadOrFail(
Expand Down Expand Up @@ -330,13 +327,13 @@ private void maybeDownloadServerLogs(ExecuteResponse resp, ActionKey actionKey)
}
}

private SpawnResult.Builder downloadRemoteResults(ActionResult result, FileOutErr outErr)
throws ExecException, IOException, InterruptedException {
remoteCache.download(result, execRoot, outErr);
int exitCode = result.getExitCode();
private SpawnResult createSpawnResult(int exitCode, boolean cacheHit) {
return new SpawnResult.Builder()
.setStatus(exitCode == 0 ? Status.SUCCESS : Status.NON_ZERO_EXIT)
.setExitCode(exitCode);
.setExitCode(exitCode)
.setRunnerName(cacheHit ? getName() + " cache hit" : getName())
.setCacheHit(cacheHit)
.build();
}

private SpawnResult execLocally(Spawn spawn, SpawnExecutionContext context)
Expand Down