... |
... |
@@ -19,6 +19,7 @@ import tempfile |
19
|
19
|
|
20
|
20
|
from google.protobuf import any_pb2
|
21
|
21
|
|
|
22
|
+from buildgrid.settings import HASH_LENGTH
|
22
|
23
|
from buildgrid.client.cas import upload
|
23
|
24
|
from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
|
24
|
25
|
from buildgrid._protos.google.bytestream import bytestream_pb2_grpc
|
... |
... |
@@ -87,17 +88,35 @@ def work_buildbox(context, lease): |
87
|
88
|
|
88
|
89
|
command_line = subprocess.Popen(command_line,
|
89
|
90
|
stdin=subprocess.PIPE,
|
90
|
|
- stdout=subprocess.PIPE)
|
91
|
|
- # TODO: Should return the stdout and stderr to the user.
|
92
|
|
- command_line.communicate()
|
|
91
|
+ stdout=subprocess.PIPE,
|
|
92
|
+ stderr=subprocess.PIPE)
|
|
93
|
+ stdout, stderr = command_line.communicate()
|
|
94
|
+ action_result = remote_execution_pb2.ActionResult()
|
|
95
|
+ # TODO: Have a decision if to upload to CAS
|
|
96
|
+ # or output raw
|
|
97
|
+ action_result.stdout_raw = stdout
|
|
98
|
+
|
|
99
|
+ def __error(msg):
|
|
100
|
+ # TODO: Have a decision if to upload to CAS
|
|
101
|
+ # or output raw
|
|
102
|
+ logger.error("Bot error: [{}]".format(msg))
|
|
103
|
+ action_result.stderr_raw = msg
|
|
104
|
+ action_result_any = any_pb2.Any()
|
|
105
|
+ action_result_any.Pack(action_result)
|
|
106
|
+ lease.result.CopyFrom(action_result_any)
|
|
107
|
+ return lease
|
|
108
|
+
|
|
109
|
+ if stderr:
|
|
110
|
+ return __error(stderr)
|
93
|
111
|
|
94
|
112
|
output_digest = remote_execution_pb2.Digest()
|
95
|
113
|
output_digest.ParseFromString(read_file(output_digest_file.name))
|
96
|
114
|
|
97
|
115
|
logger.debug("Output root digest: {}".format(output_digest))
|
98
|
116
|
|
99
|
|
- if len(output_digest.hash) < 64:
|
100
|
|
- logger.warning("Buildbox command failed - no output root digest present.")
|
|
117
|
+ if len(output_digest.hash) < HASH_LENGTH:
|
|
118
|
+ msg = "Buildbox command failed - no output root digest present."
|
|
119
|
+ return __error(msg)
|
101
|
120
|
|
102
|
121
|
# TODO: Have BuildBox helping us creating the Tree instance here
|
103
|
122
|
# See https://gitlab.com/BuildStream/buildbox/issues/7 for details
|
... |
... |
@@ -110,7 +129,6 @@ def work_buildbox(context, lease): |
110
|
129
|
output_directory.tree_digest.CopyFrom(output_tree_digest)
|
111
|
130
|
output_directory.path = os.path.relpath(working_directory, start='/')
|
112
|
131
|
|
113
|
|
- action_result = remote_execution_pb2.ActionResult()
|
114
|
132
|
action_result.output_directories.extend([output_directory])
|
115
|
133
|
|
116
|
134
|
action_result_any = any_pb2.Any()
|