aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java62
1 files changed, 32 insertions, 30 deletions
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 69b751cbda..bd53704b3d 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
@@ -27,12 +27,14 @@ import com.google.devtools.build.lib.actions.cache.VirtualActionInput;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.Reporter;
+import com.google.devtools.build.lib.exec.SpawnExecException;
import com.google.devtools.build.lib.exec.SpawnInputExpander;
import com.google.devtools.build.lib.exec.SpawnResult;
import com.google.devtools.build.lib.exec.SpawnResult.Status;
import com.google.devtools.build.lib.exec.SpawnRunner;
import com.google.devtools.build.lib.remote.Digests.ActionKey;
import com.google.devtools.build.lib.remote.TreeNodeRepository.TreeNode;
+import com.google.devtools.build.lib.util.ExitCode;
import com.google.devtools.build.lib.util.io.FileOutErr;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -209,40 +211,40 @@ class RemoteSpawnRunner implements SpawnRunner {
if (options.remoteLocalFallback) {
return execLocally(spawn, policy, inputMap, uploadLocalResults, remoteCache, actionKey);
}
- if (cause instanceof TimeoutException) {
- return handleTimeout(policy.getFileOutErr());
- }
- throw new EnvironmentalExecException(errorMessage(cause), cause, true);
- }
-
- private SpawnResult handleTimeout(FileOutErr outErr) throws IOException {
- // TODO(buchgr): Once the remote execution protocol allows it, also provide stdout/stderr
- // from the action that timed out.
- try (OutputStream out = outErr.getOutputStream()) {
- // This is a hack to ensure that the test.log file gets created, as else the action
- // will complain that one of its outputs has not been created.
- String msg = "Log output for timeouts is not yet supported in remote execution.";
- out.write(msg.getBytes(StandardCharsets.UTF_8));
- out.flush();
- }
- return new SpawnResult.Builder().setStatus(Status.TIMEOUT).build();
+ return handleError(cause, policy.getFileOutErr());
}
- private String errorMessage(IOException e) {
- String message = "";
- if (e instanceof RetryException
- && ((RetryException) e).causedByStatusCode(Code.UNAVAILABLE)) {
- message = "The remote executor/cache is unavailable";
- } else if (e instanceof CacheNotFoundException) {
- message = "Failed to download from remote cache";
+ private SpawnResult handleError(IOException cause, FileOutErr outErr) throws IOException,
+ ExecException {
+ final Status status;
+ if (cause instanceof TimeoutException) {
+ status = Status.TIMEOUT;
+ // TODO(buchgr): Once the remote execution protocol allows it, also provide stdout/stderr
+ // from the action that timed out.
+ try (OutputStream out = outErr.getOutputStream()) {
+ // This is a hack to ensure that the test.log file gets created, as else the action
+ // will complain that one of its outputs has not been created.
+ String msg = "Log output for timeouts is not yet supported in remote execution.";
+ out.write(msg.getBytes(StandardCharsets.UTF_8));
+ out.flush();
+ }
+ return new SpawnResult.Builder().setStatus(status).build();
+ } else if (cause instanceof RetryException
+ && ((RetryException) cause).causedByStatusCode(Code.UNAVAILABLE)) {
+ status = Status.CONNECTION_FAILED;
+ } else if (cause instanceof CacheNotFoundException) {
+ status = Status.REMOTE_CACHE_FAILED;
} else {
- message = "Error in remote cache/executor";
- }
- // TODO(olaola): reuse the ErrorMessage class for these errors.
- if (verboseFailures) {
- message += "\n" + Throwables.getStackTraceAsString(e);
+ status = Status.EXECUTION_FAILED;
}
- return message;
+ throw new SpawnExecException(
+ Throwables.getStackTraceAsString(cause),
+ new SpawnResult
+ .Builder()
+ .setExitCode(ExitCode.REMOTE_ERROR.getNumericExitCode())
+ .setStatus(status)
+ .build(),
+ /*catastrophic=*/true);
}
static Action buildAction(