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
=== modified file 'landscape/broker/server.py'
--- landscape/broker/server.py 2013-07-19 09:57:57 +0000
+++ landscape/broker/server.py 2014-11-06 07:42:30 +0000
@@ -191,6 +191,22 @@
191 during the next regularly scheduled exchange.191 during the next regularly scheduled exchange.
192 @return: The message identifier created when queuing C{message}.192 @return: The message identifier created when queuing C{message}.
193 """193 """
194 if isinstance(session_id, bool) and message["type"] in (
195 "operation-result", "change-packages-result"):
196 # XXX This means we're performing a Landscape-driven upgrade and
197 # we're being invoked by a package-changer or release-upgrader
198 # process that is running code which doesn't know about the
199 # session_id parameter, i.e. it was written against the old
200 # signature:
201 #
202 # def send_message(self, message, urgent=False):
203 #
204 # In this case we'll just let the message in. This transitional
205 # code can be dropped once we stop supporting clients without
206 # session IDs (i.e. with versions < 14.01).
207 urgent = True
208 session_id = self.get_session_id()
209
194 if session_id is None:210 if session_id is None:
195 raise RuntimeError(211 raise RuntimeError(
196 "Session ID must be set before attempting to send a message")212 "Session ID must be set before attempting to send a message")
197213
=== modified file 'landscape/broker/tests/test_server.py'
--- landscape/broker/tests/test_server.py 2013-09-09 14:12:05 +0000
+++ landscape/broker/tests/test_server.py 2014-11-06 07:42:30 +0000
@@ -104,6 +104,29 @@
104 self.assertRaises(104 self.assertRaises(
105 RuntimeError, self.broker.send_message, message, None)105 RuntimeError, self.broker.send_message, message, None)
106106
107 def test_send_message_with_old_release_upgrader(self):
108 """
109 If we receive a message from an old release-upgrader process that
110 doesn't know about session IDs, we just let the message in.
111 """
112 message = {"type": "operation-result", "operation-id": 99, "status": 5}
113 self.mstore.set_accepted_types(["operation-result"])
114 self.broker.send_message(message, True)
115 self.assertMessages(self.mstore.get_pending_messages(), [message])
116 self.assertTrue(self.exchanger.is_urgent())
117
118 def test_send_message_with_old_package_changer(self):
119 """
120 If we receive a message from an old package-changer process that
121 doesn't know about session IDs, we just let the message in.
122 """
123 message = {"type": "change-packages-result", "operation-id": 99,
124 "result-code": 123}
125 self.mstore.set_accepted_types(["change-packages-result"])
126 self.broker.send_message(message, True)
127 self.assertMessages(self.mstore.get_pending_messages(), [message])
128 self.assertTrue(self.exchanger.is_urgent())
129
107 def test_is_pending(self):130 def test_is_pending(self):
108 """131 """
109 The L{BrokerServer.is_pending} method indicates if a message with132 The L{BrokerServer.is_pending} method indicates if a message with

Subscribers

People subscribed via source and target branches

to all changes: