diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-03-20 14:28:17 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-03-20 14:28:17 +0000 |
commit | cf436f119567ce7190b495a86dd043a707c3f2e9 (patch) | |
tree | 28f2d32e5c95c0497132e0b465e9869f1f8e2fce | |
parent | e766a253a78ece52c4b6bb300ae7ac3e8907dd78 (diff) | |
download | morph-cf436f119567ce7190b495a86dd043a707c3f2e9.tar.gz |
fixup: Make map_build_graph more docile
Change-Id: I1b118359e024f43591ac4e475def8929d5645469
-rw-r--r-- | distbuild/build_controller.py | 58 | ||||
-rw-r--r-- | morphlib/plugins/build_plugin.py | 1 |
2 files changed, 41 insertions, 18 deletions
diff --git a/distbuild/build_controller.py b/distbuild/build_controller.py index b4014b9b..23c37f68 100644 --- a/distbuild/build_controller.py +++ b/distbuild/build_controller.py @@ -126,9 +126,10 @@ def build_step_name(artifact): def map_build_graph(artifact, callback, components=[]): result = [] + mapped_components = [] done = set() if components: - queue = components + queue = list(components) else: queue = [artifact] while queue: @@ -137,7 +138,9 @@ def map_build_graph(artifact, callback, components=[]): result.append(callback(a)) queue.extend(a.source.dependencies) done.add(a) - return result + if a in components: + mapped_components.append(a) + return result, mapped_components def find_artifacts(components, artifact): @@ -337,8 +340,13 @@ class BuildController(distbuild.StateMachine): self._artifact = event.artifact filenames = self._request['component_filenames'] self._components = find_artifacts(filenames, self._artifact) - if len(self._components) != len(filenames) \ - and self._request['partial']: + failed = False + for component in self._components: + if component.source.filename not in filenames: + logging.debug('Failed to find %s in build graph' + % component.filename) + failed = True + if failed: self.fail('Failed to find all components in %s' % self._artifact.name) self._helper_id = self._idgen.next() @@ -348,7 +356,9 @@ class BuildController(distbuild.StateMachine): artifact.state = UNKNOWN artifact_names.append(artifact.basename()) - map_build_graph(self._artifact, set_state_and_append) + _, self._components = map_build_graph(self._artifact, + set_state_and_append, + self._components) url = urlparse.urljoin(self._artifact_cache_server, '/1.0/artifacts') msg = distbuild.message('http-request', @@ -383,11 +393,14 @@ class BuildController(distbuild.StateMachine): return cache_state = json.loads(event.msg['body']) - map_build_graph(self._artifact, set_status) + _, self._components = map_build_graph(self._artifact, set_status, + self._components) self.mainloop.queue_event(self, _Annotated()) - count = sum(map_build_graph(self._artifact, - lambda a: 1 if a.state == UNBUILT else 0)) + arts, _ = map_build_graph(self._artifact, + lambda a: 1 if a.state == UNBUILT else 0, + self._components) + count = sum(arts) progress = BuildProgress( self._request['id'], @@ -404,22 +417,30 @@ class BuildController(distbuild.StateMachine): all(a.state == BUILT for a in artifact.source.dependencies)) - return [a - for a in map_build_graph(self._artifact, lambda a: a) - if is_ready_to_build(a)] + artifacts, _ = map_build_graph(self._artifact, lambda a: a, + self._components) + return [a for a in artifacts if is_ready_to_build(a)] def _queue_worker_builds(self, event_source, event): distbuild.crash_point() - if self._artifact.state == BUILT: - logging.info('Requested artifact is built') - self.mainloop.queue_event(self, _Built()) - return + if not self._components: + if self._artifact.state == BUILT: + logging.info('Requested artifact is built') + self.mainloop.queue_event(self, _Built()) + return + + else: + if not any(c.state != BUILT for c in self._components): + logging.info('Requested components are built') + self.mainloop.queue_event(self, _Built()) + return logging.debug('Queuing more worker-builds to run') if self.debug_graph_state: logging.debug('Current state of build graph nodes:') - for a in map_build_graph(self._artifact, lambda a: a): + for a, _ in map_build_graph(self._artifact, + lambda a: a, self._components): logging.debug(' %s state is %s' % (a.name, a.state)) if a.state != BUILT: for dep in a.dependencies: @@ -553,7 +574,7 @@ class BuildController(distbuild.StateMachine): self.mainloop.queue_event(BuildController, progress) def _find_artifact(self, cache_key): - artifacts = map_build_graph(self._artifact, lambda a: a) + artifacts, _ = map_build_graph(self._artifact, lambda a: a, self._components) wanted = [a for a in artifacts if a.source.cache_key == cache_key] if wanted: return wanted[0] @@ -588,7 +609,8 @@ class BuildController(distbuild.StateMachine): # yields all chunk artifacts for the given source # so we set the state of this source's artifacts # to BUILT - map_build_graph(self._artifact, set_state) + _, self._components = map_build_graph(self._artifact, set_state, + self._components) self._queue_worker_builds(None, event) diff --git a/morphlib/plugins/build_plugin.py b/morphlib/plugins/build_plugin.py index b792d7c7..807fba0e 100644 --- a/morphlib/plugins/build_plugin.py +++ b/morphlib/plugins/build_plugin.py @@ -312,6 +312,7 @@ class BuildPlugin(cliapp.Plugin): bc.build(repo, commit, system_filename, original_ref=original_ref, component_filenames=component_filenames) + return if not self.app.settings['partial']: if original_ref: bc.build(repo, commit, system_filename, |