diff options
Diffstat (limited to 'distbuild/build_controller.py')
-rw-r--r-- | distbuild/build_controller.py | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/distbuild/build_controller.py b/distbuild/build_controller.py index 35b231f9..a0dba147 100644 --- a/distbuild/build_controller.py +++ b/distbuild/build_controller.py @@ -174,6 +174,13 @@ class BuildController(distbuild.StateMachine): self._helper_id = None self.debug_transitions = False self.debug_graph_state = False + self.allow_detach = build_request_message['allow_detach'] + self.build_status = 'Building' + self.build_info = { + 'id': build_request_message['id'], + 'morphology': build_request_message['morphology'], + 'build-status': self.build_status, + } def __repr__(self): return '<BuildController at 0x%x, request-id %s>' % (id(self), @@ -185,6 +192,14 @@ class BuildController(distbuild.StateMachine): def get_request(self): return self._request + def get_status(self): + return self.build_status + + def get_status_message(self): + return ('Build request ID: %s\n System build: %s\n Build status: %s' % + (self.build_info['id'], self.build_info['morphology'], + self.build_status)) + def setup(self): distbuild.crash_point() @@ -496,10 +511,18 @@ class BuildController(distbuild.StateMachine): logging.debug("BuildController %r: initiator id %s disconnected", self, event.id) - cancel_pending = distbuild.WorkerCancelPending(event.id) - self.mainloop.queue_event(distbuild.WorkerBuildQueuer, cancel_pending) + if self.allow_detach: + logging.debug('Detaching from client; build continuing remotely.') + else: + self.mainloop.queue_event(self, build_cancel(event.id)) + self.build_status = 'Cancelled' + + def build_cancel(self, event_id): + cancel_pending = distbuild.WorkerCancelPending(event_id) + self.mainloop.queue_event(distbuild.WorkerBuildQueuer, + cancel_pending) - cancel = BuildCancel(event.id) + cancel = BuildCancel(event_id) self.mainloop.queue_event(BuildController, cancel) self.mainloop.queue_event(self, _Abort()) @@ -533,6 +556,7 @@ class BuildController(distbuild.StateMachine): return logging.debug('BC: got build step started: %s' % artifact.name) + self.build_status = ('Building %s' % artifact.name) started = BuildStepStarted( self._request['id'], build_step_name(artifact), event.worker_name) self.mainloop.queue_event(BuildController, started) @@ -652,6 +676,8 @@ class BuildController(distbuild.StateMachine): self.fail('Building failed for %s' % artifact.name) + self.build_status = ('Failed building %s' % artifact.name) + # Cancel any jobs waiting to be executed, since there is no point # running them if this build has failed, it would just waste # resources @@ -671,6 +697,7 @@ class BuildController(distbuild.StateMachine): distbuild.crash_point() logging.debug('Notifying initiator of successful build') + self.build_status = 'Finished' baseurl = urlparse.urljoin( self._artifact_cache_server, '/1.0/artifacts') urls = [] |