summaryrefslogtreecommitdiff
path: root/distbuild/initiator_connection.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_connection.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_connection.py')
-rw-r--r--distbuild/initiator_connection.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/distbuild/initiator_connection.py b/distbuild/initiator_connection.py
index 54322f6a..fdb1dab5 100644
--- a/distbuild/initiator_connection.py
+++ b/distbuild/initiator_connection.py
@@ -98,6 +98,21 @@ class InitiatorConnection(distbuild.StateMachine):
event.msg)
try:
+ if event.msg.get('protocol_version') != distbuild.protocol.VERSION:
+ msg = distbuild.message('build-failed',
+ # use build-failed as it is understood by older versions of
+ # morph; if morph is old enough (protocol_version < 1) it
+ # won't understand a new message and ignore it or cause the
+ # request to hang
+ id=event.msg['id'],
+ reason=('Protocol version mismatch between server & '
+ 'initiator: distbuild network uses distbuild '
+ 'protocol version %i, but client uses version %i.'
+ % (distbuild.protocol.VERSION,
+ event.msg.get('protocol_version'))))
+ self.jm.send(msg)
+ self._log_send(msg)
+ return
if event.msg['type'] == 'build-request':
self._handle_build_request(event)
elif event.msg['type'] == 'list-requests':
@@ -109,17 +124,6 @@ class InitiatorConnection(distbuild.StateMachine):
event.msg, ex)
def _handle_build_request(self, event):
- if event.msg.get('protocol_version') != distbuild.protocol.VERSION:
- msg = distbuild.message('build-failed',
- id=event.msg['id'],
- reason=('Protocol version mismatch between server & initiator:'
- ' distbuild network uses distbuild protocol version %i'
- ', but client uses version %i.' % (
- distbuild.protocol.VERSION,
- event.msg.get('protocol_version'))))
- self.jm.send(msg)
- self._log_send(msg)
- return
new_id = self._idgen.next()
self.our_ids.add(new_id)
self._route_map.add(event.msg['id'], new_id)
@@ -143,7 +147,7 @@ class InitiatorConnection(distbuild.StateMachine):
build.get_request()['repo'],
build.get_request()['ref'],
build.get_request()['morphology']))
- msg = distbuild.message('list-request-output',
+ msg = distbuild.message('request-output',
message=('\n\n'.join(output_msg)))
self.jm.send(msg)