Skip to content
Snippets Groups Projects
Commit 9dd954df authored by finnball's avatar finnball
Browse files

If BuildBox fails, raise error.

Will also return stdout to client.
parent afdcb559
No related branches found
No related tags found
Loading
......@@ -19,7 +19,9 @@ import tempfile
from google.protobuf import any_pb2
from buildgrid.settings import HASH_LENGTH
from buildgrid.client.cas import upload
from buildgrid._exceptions import BotError
from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
from buildgrid._protos.google.bytestream import bytestream_pb2_grpc
from buildgrid.utils import read_file, write_file, parse_to_pb2_from_fetch
......@@ -87,17 +89,30 @@ def work_buildbox(context, lease):
command_line = subprocess.Popen(command_line,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
# TODO: Should return the stdout and stderr to the user.
command_line.communicate()
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = command_line.communicate()
action_result = remote_execution_pb2.ActionResult()
# TODO: Upload to CAS or output RAW
# For now, just pass raw
# https://gitlab.com/BuildGrid/buildgrid/issues/90
action_result.stdout_raw = stdout
if stderr:
# TODO: Upload to CAS or output RAW
# For now, just pass raw
# https://gitlab.com/BuildGrid/buildgrid/issues/90
logger.error("BuildBox error: [{}]".format(stderr))
raise BotError(stderr, detail=stdout, reason="Captured stderr")
output_digest = remote_execution_pb2.Digest()
output_digest.ParseFromString(read_file(output_digest_file.name))
logger.debug("Output root digest: {}".format(output_digest))
if len(output_digest.hash) < 64:
logger.warning("Buildbox command failed - no output root digest present.")
if len(output_digest.hash) < HASH_LENGTH:
raise BotError("Output hash length too small",
detail=stdout, reason="No output root digest present.")
# TODO: Have BuildBox helping us creating the Tree instance here
# See https://gitlab.com/BuildStream/buildbox/issues/7 for details
......@@ -110,7 +125,6 @@ def work_buildbox(context, lease):
output_directory.tree_digest.CopyFrom(output_tree_digest)
output_directory.path = os.path.relpath(working_directory, start='/')
action_result = remote_execution_pb2.ActionResult()
action_result.output_directories.extend([output_directory])
action_result_any = any_pb2.Any()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment