Fix updating subscription options in Redis driver
Now, if you try to update subscription in Redis and specify new options, these options will be written to database in plain text format instead of MessagePack format. Then, if you try to get this subscription, Zaqar will return response with code 503. Internally Zaqar will experience a problem while trying to unpack subscription's options. This patch makes Redis driver on HTTP PATCH method pack subscription options in MessagePack format, before sending changes to database. Change-Id: Ic3940b5093021c0d0cc5c345acabe29804d5a291 Closes-Bug: 1554683
This commit is contained in:
parent
11247caec4
commit
146e37c70f
@ -183,6 +183,11 @@ class SubscriptionController(base.Subscription):
|
||||
key_transform=key_transform)
|
||||
assert fields, ('`subscriber`, `ttl`, '
|
||||
'or `options` not found in kwargs')
|
||||
# NOTE(Eva-i): if there are new options, we need to pack them before
|
||||
# sending to the database.
|
||||
new_options = fields.get('o', None)
|
||||
if new_options is not None:
|
||||
fields['o'] = self._packer(new_options)
|
||||
|
||||
# Pipeline ensures atomic inserts.
|
||||
with self._client.pipeline() as pipe:
|
||||
|
@ -1051,7 +1051,8 @@ class SubscriptionControllerTest(ControllerBaseTest):
|
||||
self.subscription_controller.update(self.queue_name,
|
||||
s_id,
|
||||
project=self.project,
|
||||
subscriber='http://a.com'
|
||||
subscriber='http://a.com',
|
||||
options={'funny': 'no'}
|
||||
)
|
||||
|
||||
updated = self.subscription_controller.get(self.queue_name,
|
||||
@ -1059,6 +1060,7 @@ class SubscriptionControllerTest(ControllerBaseTest):
|
||||
self.project)
|
||||
|
||||
self.assertEqual('http://a.com', updated['subscriber'])
|
||||
self.assertEqual({'funny': 'no'}, updated['options'])
|
||||
|
||||
self.subscription_controller.delete(self.queue_name,
|
||||
s_id, project=self.project)
|
||||
|
Loading…
Reference in New Issue
Block a user