From 16cf9d5f6c2b05fbf770a9194c0cee531f5bc2f9 Mon Sep 17 00:00:00 2001 From: Martin Blanchard Date: Mon, 24 Sep 2018 14:39:29 +0100 Subject: _sandboxremote.py: Handle remote build execution exit code https://gitlab.com/BuildStream/buildstream/issues/668 --- buildstream/sandbox/_sandboxremote.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/buildstream/sandbox/_sandboxremote.py b/buildstream/sandbox/_sandboxremote.py index 2fca53a96..6a49ec4bb 100644 --- a/buildstream/sandbox/_sandboxremote.py +++ b/buildstream/sandbox/_sandboxremote.py @@ -27,6 +27,7 @@ from . import Sandbox from ..storage._filebaseddirectory import FileBasedDirectory from ..storage._casbaseddirectory import CasBasedDirectory from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2, remote_execution_pb2_grpc +from .._protos.google.rpc import code_pb2 from .._platform import Platform @@ -207,15 +208,23 @@ class SandboxRemote(Sandbox): operation.response.Unpack(execution_response) - if execution_response.status.code != 0: - # A normal error during the build: the remote execution system - # has worked correctly but the command failed. - # execution_response.error also contains 'message' (str) and - # 'details' (iterator of Any) which we ignore at the moment. - return execution_response.status.code + if execution_response.status.code != code_pb2.OK: + # An unexpected error during execution: the remote execution + # system failed at processing the execution request. + if execution_response.status.message: + raise SandboxError(execution_response.status.message) + else: + raise SandboxError("Remote server failed at executing the build request.") action_result = execution_response.result + if action_result.exit_code != 0: + # A normal error during the build: the remote execution system + # has worked correctly but the command failed. + # action_result.stdout and action_result.stderr also contains + # build command outputs which we ignore at the moment. + return action_result.exit_code + self.process_job_output(action_result.output_directories, action_result.output_files) return 0 -- cgit v1.2.1