diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-03-16 15:10:42 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-03-16 15:10:42 +0000 |
commit | 9bf85ad75d38703e2ed28434f58acd1a13b6df83 (patch) | |
tree | 4cc87900b916f4bce1b4efd9953d3194b3f339f4 | |
parent | 42bc88e06447c9c136c828c21eccd42eb9128085 (diff) | |
download | morph-9bf85ad75d38703e2ed28434f58acd1a13b6df83.tar.gz |
WIP: partial distbuilds
-rw-r--r-- | distbuild/build_controller.py | 19 | ||||
-rw-r--r-- | distbuild/initiator.py | 8 | ||||
-rw-r--r-- | distbuild/protocol.py | 6 | ||||
-rw-r--r-- | morphlib/buildcommand.py | 6 | ||||
-rw-r--r-- | morphlib/plugins/build_plugin.py | 4 |
5 files changed, 36 insertions, 7 deletions
diff --git a/distbuild/build_controller.py b/distbuild/build_controller.py index aa11ae8f..e2a63472 100644 --- a/distbuild/build_controller.py +++ b/distbuild/build_controller.py @@ -124,10 +124,13 @@ def build_step_name(artifact): return artifact.name -def map_build_graph(artifact, callback): +def map_build_graph(artifact, callback, components=[]): result = [] done = set() - queue = [artifact] + if components: + queue = components + else: + queue = [artifact] while queue: a = queue.pop() if a not in done: @@ -137,6 +140,13 @@ def map_build_graph(artifact, callback): return result +def find_artifacts(components, artifact): + found = [] + for a in artifact.walk(): + if a.source.filename in components: + found.append(a) + return found + class BuildController(distbuild.StateMachine): '''Control one build-request fulfillment. @@ -325,6 +335,11 @@ class BuildController(distbuild.StateMachine): distbuild.crash_point() 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']: + raise morphlib.Error('its too much sock') self._helper_id = self._idgen.next() artifact_names = [] diff --git a/distbuild/initiator.py b/distbuild/initiator.py index 7f82827c..a63ac418 100644 --- a/distbuild/initiator.py +++ b/distbuild/initiator.py @@ -40,7 +40,7 @@ class _Failed(object): class Initiator(distbuild.StateMachine): def __init__(self, cm, conn, app, repo_name, ref, morphology, - original_ref): + original_ref, component_filenames): distbuild.StateMachine.__init__(self, 'waiting') self._cm = cm self._conn = conn @@ -49,6 +49,10 @@ class Initiator(distbuild.StateMachine): self._ref = ref self._morphology = morphology self._original_ref = original_ref + self._component_filenames = component_filenames + self._partial = False + if self._component_filenames: + self._partial = True self._steps = None self._step_outputs = {} self._step_output_dir = app.settings['initiator-step-output-dir'] @@ -84,6 +88,8 @@ class Initiator(distbuild.StateMachine): ref=self._ref, morphology=self._morphology, original_ref=self._original_ref, + component_filenames=self._component_filenames, + partial=self._partial, protocol_version=distbuild.protocol.VERSION ) self._jm.send(msg) diff --git a/distbuild/protocol.py b/distbuild/protocol.py index f2c74819..684c2f57 100644 --- a/distbuild/protocol.py +++ b/distbuild/protocol.py @@ -23,7 +23,7 @@ # time a change is introduced that would break server/initiator compatibility -VERSION = 1 +VERSION = 2 _required_fields = { @@ -32,6 +32,7 @@ _required_fields = { 'repo', 'ref', 'morphology', + 'partial', 'protocol_version', ], 'build-progress': [ @@ -94,7 +95,8 @@ _required_fields = { _optional_fields = { 'build-request': [ - 'original_ref' + 'original_ref', + 'component_filenames' ] } diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py index 4e63b211..a6b3b9da 100644 --- a/morphlib/buildcommand.py +++ b/morphlib/buildcommand.py @@ -524,7 +524,8 @@ class InitiatorBuildCommand(BuildCommand): self.app.settings['push-build-branches'] = True super(InitiatorBuildCommand, self).__init__(app) - def build(self, repo_name, ref, filename, original_ref=None): + def build(self, repo_name, ref, filename, original_ref=None, + component_filenames=[]): '''Initiate a distributed build on a controller''' distbuild.add_crash_conditions(self.app.settings['crash-condition']) @@ -535,7 +536,8 @@ class InitiatorBuildCommand(BuildCommand): self.app.status(msg='Starting distributed build') loop = distbuild.MainLoop() - args = [repo_name, ref, filename, original_ref or ref] + args = [repo_name, ref, filename, original_ref or ref, + component_filenames] cm = distbuild.InitiatorConnectionMachine(self.app, self.addr, self.port, diff --git a/morphlib/plugins/build_plugin.py b/morphlib/plugins/build_plugin.py index 15ae962a..b792d7c7 100644 --- a/morphlib/plugins/build_plugin.py +++ b/morphlib/plugins/build_plugin.py @@ -308,6 +308,10 @@ class BuildPlugin(cliapp.Plugin): these in and build each one in turn. ''' + if self.use_distbuild: + bc.build(repo, commit, system_filename, + original_ref=original_ref, + component_filenames=component_filenames) if not self.app.settings['partial']: if original_ref: bc.build(repo, commit, system_filename, |