Merge lp:~free.ekanayaka/landscape-client/fix-upgrades-to-14.01 into lp:~landscape/landscape-client/trunk

Proposed by Free Ekanayaka
Status: Merged
Approved by: Free Ekanayaka
Approved revision: 794
Merged at revision: 793
Proposed branch: lp:~free.ekanayaka/landscape-client/fix-upgrades-to-14.01
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 60 lines (+39/-0)
2 files modified
landscape/broker/server.py (+16/-0)
landscape/broker/tests/test_server.py (+23/-0)
To merge this branch: bzr merge lp:~free.ekanayaka/landscape-client/fix-upgrades-to-14.01
Reviewer Review Type Date Requested Status
Benji York (community) Approve
Alberto Donato (community) Approve
Review via email: mp+240722@code.launchpad.net

Commit message

Fix upgrades from < 14.01 to >= 14.01 by working around the change in
the BrokerServer.send_message signature.

Description of the change

Fix upgrades from < 14.01 to >= 14.01 by working around the change in
the BrokerServer.send_message signature.

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

Nice catch, +1

review: Approve
Revision history for this message
Benji York (benji) wrote :

Very nice. I had one less-than-trivial thought inline.

review: Approve
794. By Free Ekanayaka

Address review comments

Revision history for this message
Free Ekanayaka (free.ekanayaka) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/broker/server.py'
2--- landscape/broker/server.py 2013-07-19 09:57:57 +0000
3+++ landscape/broker/server.py 2014-11-06 07:42:30 +0000
4@@ -191,6 +191,22 @@
5 during the next regularly scheduled exchange.
6 @return: The message identifier created when queuing C{message}.
7 """
8+ if isinstance(session_id, bool) and message["type"] in (
9+ "operation-result", "change-packages-result"):
10+ # XXX This means we're performing a Landscape-driven upgrade and
11+ # we're being invoked by a package-changer or release-upgrader
12+ # process that is running code which doesn't know about the
13+ # session_id parameter, i.e. it was written against the old
14+ # signature:
15+ #
16+ # def send_message(self, message, urgent=False):
17+ #
18+ # In this case we'll just let the message in. This transitional
19+ # code can be dropped once we stop supporting clients without
20+ # session IDs (i.e. with versions < 14.01).
21+ urgent = True
22+ session_id = self.get_session_id()
23+
24 if session_id is None:
25 raise RuntimeError(
26 "Session ID must be set before attempting to send a message")
27
28=== modified file 'landscape/broker/tests/test_server.py'
29--- landscape/broker/tests/test_server.py 2013-09-09 14:12:05 +0000
30+++ landscape/broker/tests/test_server.py 2014-11-06 07:42:30 +0000
31@@ -104,6 +104,29 @@
32 self.assertRaises(
33 RuntimeError, self.broker.send_message, message, None)
34
35+ def test_send_message_with_old_release_upgrader(self):
36+ """
37+ If we receive a message from an old release-upgrader process that
38+ doesn't know about session IDs, we just let the message in.
39+ """
40+ message = {"type": "operation-result", "operation-id": 99, "status": 5}
41+ self.mstore.set_accepted_types(["operation-result"])
42+ self.broker.send_message(message, True)
43+ self.assertMessages(self.mstore.get_pending_messages(), [message])
44+ self.assertTrue(self.exchanger.is_urgent())
45+
46+ def test_send_message_with_old_package_changer(self):
47+ """
48+ If we receive a message from an old package-changer process that
49+ doesn't know about session IDs, we just let the message in.
50+ """
51+ message = {"type": "change-packages-result", "operation-id": 99,
52+ "result-code": 123}
53+ self.mstore.set_accepted_types(["change-packages-result"])
54+ self.broker.send_message(message, True)
55+ self.assertMessages(self.mstore.get_pending_messages(), [message])
56+ self.assertTrue(self.exchanger.is_urgent())
57+
58 def test_is_pending(self):
59 """
60 The L{BrokerServer.is_pending} method indicates if a message with

Subscribers

People subscribed via source and target branches

to all changes: