diff options
author | 2017-09-28 14:18:46 -0400 | |
---|---|---|
committer | 2017-09-29 12:13:57 -0400 | |
commit | 6cafc1fdb6aacbc5d15e97245845e7079abb5e1b (patch) | |
tree | 114348ee3e1f2f89612d360d9d0006a20a6f3dc5 /src/main/java/com/google/devtools/build/lib/remote | |
parent | badd4f9615e8a7523a3404f1462192dd7506c625 (diff) |
Checking both old and new error fields on remote execute operation.
The old field is the error on Operation proto. The new field is the ExecuteResponse status field.
Note that the new field will also allow us to fetch logs for timing out tests, resolving a TODO, but this is not yet done is this change.
PiperOrigin-RevId: 170370676
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/remote')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutor.java | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutor.java b/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutor.java index a1a5427766..cdb8197366 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutor.java @@ -69,20 +69,31 @@ class GrpcRemoteExecutor { .withCallCredentials(callCredentials); } + private void handleStatus(Status statusProto) throws IOException { + StatusRuntimeException e = StatusProto.toStatusRuntimeException(statusProto); + if (e.getStatus().getCode() == Code.OK) { + return; + } + if (e.getStatus().getCode() == Code.DEADLINE_EXCEEDED) { + // This was caused by the command itself exceeding the timeout, + // therefore it is not retriable. + throw new TimeoutException(); + } + throw e; + } + private @Nullable ExecuteResponse getOperationResponse(Operation op) throws IOException { if (op.getResultCase() == Operation.ResultCase.ERROR) { - StatusRuntimeException e = StatusProto.toStatusRuntimeException(op.getError()); - if (e.getStatus().getCode() == Code.DEADLINE_EXCEEDED) { - // This was caused by the command itself exceeding the timeout, - // therefore it is not retriable. - throw new TimeoutException(); - } - throw e; + handleStatus(op.getError()); } if (op.getDone()) { Preconditions.checkState(op.getResultCase() != Operation.ResultCase.RESULT_NOT_SET); try { - return op.getResponse().unpack(ExecuteResponse.class); + ExecuteResponse resp = op.getResponse().unpack(ExecuteResponse.class); + if (resp.hasStatus()) { + handleStatus(resp.getStatus()); + } + return resp; } catch (InvalidProtocolBufferException e) { throw new IOException(e); } |