summaryrefslogtreecommitdiff
path: root/distbuild/initiator.py
diff options
context:
space:
mode:
authorLauren Perry <lauren.perry@codethink.co.uk>2015-04-21 11:25:29 +0100
committerBaserock Gerrit <gerrit@baserock.org>2015-04-29 16:03:05 +0000
commit4a1c2d118511da067fcadf2253fdc2a49d04e4fa (patch)
treeae1bbe9ed147e6ffad5b8f541af1eab9dc051fd9 /distbuild/initiator.py
parent8875e9cac2789b421c7160145bc1800db4ad1a55 (diff)
downloadmorph-4a1c2d118511da067fcadf2253fdc2a49d04e4fa.tar.gz
distbuild: Add protocol version checking for list-jobs command
Currently, the distbuild-list-jobs command will fail if morph is outdated (i.e. protocol version for client and distbuild network don't match); a protocol_version field has been added to the list-jobs request message to fix this. Moved version check outside build-request message to reduce duplication in new functions. Generalised the list-request output to reduce duplication for any further additions that may require a message output. Change-Id: I28e733cbfe8c89e8c11427df5d40ab275abd313c
Diffstat (limited to 'distbuild/initiator.py')
-rw-r--r--distbuild/initiator.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/distbuild/initiator.py b/distbuild/initiator.py
index 0119ecd6..332d54a1 100644
--- a/distbuild/initiator.py
+++ b/distbuild/initiator.py
@@ -285,6 +285,7 @@ class InitiatorListJobs(distbuild.StateMachine):
self._app.status(msg='Requesting currently running distbuilds.')
msg = distbuild.message('list-requests',
id=msg_uuid,
+ protocol_version=distbuild.protocol.VERSION
)
self._jm.send(msg)
logging.debug('Initiator: sent to controller: %s', repr(msg))
@@ -295,13 +296,22 @@ class InitiatorListJobs(distbuild.StateMachine):
logging.debug('Initiator: from controller: %s', str(event.msg))
handlers = {
- 'list-request-output': self._handle_list_request_output,
+ # set build-failed rather than request-failed so old versions of
+ # morph recognise the message and don't ignore it
+ 'build-failed': self._handle_request_failed,
+ 'request-output': self._handle_request_output,
}
handler = handlers[event.msg['type']]
handler(event.msg)
- def _handle_list_request_output(self, msg):
+ def _handle_request_failed(self, msg):
+ self._app.status(msg=str(msg['reason']))
+ self.mainloop.queue_event(self, _Failed(msg))
+ self.mainloop.queue_event(self._cm, distbuild.StopConnecting())
+ self._jm.close()
+
+ def _handle_request_output(self, msg):
self._app.status(msg=str(msg['message']))
self.mainloop.queue_event(self._cm, distbuild.StopConnecting())
self._jm.close()