Fix compatability with new oslo.messaging
A recent change to oslo.messaging to redact contexts before sending them to a notification bus broke masakari due to the invalid default for read_deleted. This ensures that a "None" value for read_deleted ends up being interpreted as a 'none'. Related-bug: #2030976 Change-Id: Ic9b895601f301c1e9ba135766493d4234fa9b50b
This commit is contained in:
parent
09d595849d
commit
6a48417607
@ -117,7 +117,12 @@ class RequestContext(context.RequestContext):
|
||||
LOG.debug('Arguments dropped when creating context: %s',
|
||||
str(kwargs))
|
||||
|
||||
self.read_deleted = read_deleted
|
||||
if read_deleted is None:
|
||||
# If we did not get a value for read_deleted, ensure we default
|
||||
# it to "no" as code expects it to be a string.
|
||||
self.read_deleted = 'no'
|
||||
else:
|
||||
self.read_deleted = read_deleted
|
||||
self.remote_address = remote_address
|
||||
if not timestamp:
|
||||
timestamp = timeutils.utcnow()
|
||||
|
@ -57,6 +57,11 @@ class ContextTestCase(test.NoDBTestCase):
|
||||
ctxt.read_deleted = 'no'
|
||||
self.assertEqual('no', ctxt.read_deleted)
|
||||
|
||||
def test_request_context_read_deleted_none(self):
|
||||
ctxt = context.RequestContext('111',
|
||||
'222')
|
||||
self.assertEqual('no', ctxt.read_deleted)
|
||||
|
||||
def test_request_context_read_deleted_invalid(self):
|
||||
self.assertRaises(ValueError,
|
||||
context.RequestContext,
|
||||
|
Loading…
Reference in New Issue
Block a user