From 99b9efa9dd588afdc4f1e189380a4c71bbc7114e Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Wed, 23 Apr 2014 17:02:05 +0100 Subject: Add handling for new messages to BuildController There are two new messages: WorkerBuildStepAlreadyStarted tells the initiator that the artifact they want to build is already being built, e.g. 'eglibc-misc is already building on 172.17.1.37:3434' WorkerBuildWaiting tells the initiator that the artifact they want to build can't be built yet because there aren't any workers free, e.g. 'Ready to build eglibc-misc: waiting for a worker to become available' --- distbuild/build_controller.py | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/distbuild/build_controller.py b/distbuild/build_controller.py index da9e97c1..31828979 100644 --- a/distbuild/build_controller.py +++ b/distbuild/build_controller.py @@ -93,7 +93,12 @@ class BuildStepStarted(object): self.id = request_id self.step_name = step_name self.worker_name = worker_name - + +class BuildStepAlreadyStarted(BuildStepStarted): + + def __init__(self, request_id, step_name, worker_name): + super(BuildStepAlreadyStarted, self).__init__( + request_id, step_name, worker_name) class BuildOutput(object): @@ -206,6 +211,7 @@ class BuildController(distbuild.StateMachine): # specific to WorkerConnection instances that our currently # building for us, but the state machines are not intended to # behave that way). + ('building', distbuild.WorkerConnection, distbuild.WorkerBuildStepStarted, 'building', self._maybe_relay_build_step_started), @@ -215,6 +221,12 @@ class BuildController(distbuild.StateMachine): ('building', distbuild.WorkerConnection, distbuild.WorkerBuildCaching, 'building', self._maybe_relay_build_caching), + ('building', distbuild.WorkerConnection, + distbuild.WorkerBuildStepAlreadyStarted, 'building', + self._maybe_relay_build_step_already_started), + ('building', distbuild.WorkerConnection, + distbuild.WorkerBuildWaiting, 'building', + self._maybe_relay_build_waiting_for_worker), ('building', distbuild.WorkerConnection, distbuild.WorkerBuildFinished, 'building', self._maybe_check_result_and_queue_more_builds), @@ -438,6 +450,21 @@ class BuildController(distbuild.StateMachine): cancel = BuildCancel(disconnect.id) self.mainloop.queue_event(BuildController, cancel) + def _maybe_relay_build_waiting_for_worker(self, event_source, event): + if event.initiator_id != self._request['id']: + return # not for us + + artifact = self._find_artifact(event.artifact_cache_key) + if artifact is None: + # This is not the event you are looking for. + return + + progress = BuildProgress( + self._request['id'], + 'Ready to build %s: waiting for a worker to become available' + % artifact.name) + self.mainloop.queue_event(BuildController, progress) + def _maybe_relay_build_step_started(self, event_source, event): distbuild.crash_point() if event.initiator_id != self._request['id']: @@ -456,6 +483,18 @@ class BuildController(distbuild.StateMachine): self.mainloop.queue_event(BuildController, started) logging.debug('BC: emitted %s' % repr(started)) + def _maybe_relay_build_step_already_started(self, event_source, event): + if event.initiator_id != self._request['id']: + return # not for us + + artifact = self._find_artifact(event.artifact_cache_key) + + logging.debug('BC: got build step already started: %s' % artifact.name) + started = BuildStepAlreadyStarted( + self._request['id'], build_step_name(artifact), event.worker_name) + self.mainloop.queue_event(BuildController, started) + logging.debug('BC: emitted %s' % repr(started)) + def _maybe_relay_build_output(self, event_source, event): distbuild.crash_point() if event.msg['id'] != self._request['id']: -- cgit v1.2.1