Merge "Retry support for oslo_messaging_notifications driver"
This commit is contained in:
commit
c8ee259bac
oslo_messaging
releasenotes/notes
@ -54,6 +54,10 @@ _notifier_opts = [
|
||||
group='DEFAULT')
|
||||
],
|
||||
help='AMQP topic used for OpenStack notifications.'),
|
||||
cfg.IntOpt('retry', default=-1,
|
||||
help='The maximum number of attempts to re-send a notification '
|
||||
'message which failed to be delivered due to a '
|
||||
'recoverable error. 0 - No retry, -1 - indefinite'),
|
||||
]
|
||||
|
||||
_LOG = logging.getLogger(__name__)
|
||||
@ -243,7 +247,10 @@ class Notifier(object):
|
||||
|
||||
self.transport = transport
|
||||
self.publisher_id = publisher_id
|
||||
self.retry = retry
|
||||
if retry is not None:
|
||||
self.retry = retry
|
||||
else:
|
||||
self.retry = conf.oslo_messaging_notifications.retry
|
||||
|
||||
self._driver_names = ([driver] if driver is not None else
|
||||
conf.oslo_messaging_notifications.driver)
|
||||
|
@ -214,7 +214,7 @@ class TestMessagingNotifier(test_utils.BaseTestCase):
|
||||
if hasattr(self, 'retry'):
|
||||
send_kwargs['retry'] = self.retry
|
||||
else:
|
||||
send_kwargs['retry'] = None
|
||||
send_kwargs['retry'] = -1
|
||||
target = oslo_messaging.Target(topic='%s.%s' % (topic,
|
||||
self.priority))
|
||||
calls.append(mock.call(target,
|
||||
@ -273,7 +273,7 @@ class TestSerializer(test_utils.BaseTestCase):
|
||||
'timestamp': str(timeutils.utcnow()),
|
||||
}
|
||||
|
||||
self.assertEqual([(dict(user='alice'), message, 'INFO', None)],
|
||||
self.assertEqual([(dict(user='alice'), message, 'INFO', -1)],
|
||||
_impl_test.NOTIFICATIONS)
|
||||
|
||||
uuid.uuid4.assert_called_once_with()
|
||||
@ -375,6 +375,31 @@ class TestLogNotifier(test_utils.BaseTestCase):
|
||||
logger.info.assert_called_once_with(mask_str)
|
||||
|
||||
|
||||
class TestNotificationConfig(test_utils.BaseTestCase):
|
||||
|
||||
def test_retry_config(self):
|
||||
conf = self.messaging_conf.conf
|
||||
self.config(driver=['messaging'],
|
||||
group='oslo_messaging_notifications')
|
||||
|
||||
conf.set_override('retry', 3, group='oslo_messaging_notifications')
|
||||
transport = _FakeTransport(conf)
|
||||
notifier = oslo_messaging.Notifier(transport)
|
||||
|
||||
self.assertEqual(3, notifier.retry)
|
||||
|
||||
def test_notifier_retry_config(self):
|
||||
conf = self.messaging_conf.conf
|
||||
self.config(driver=['messaging'],
|
||||
group='oslo_messaging_notifications')
|
||||
|
||||
conf.set_override('retry', 3, group='oslo_messaging_notifications')
|
||||
transport = _FakeTransport(conf)
|
||||
notifier = oslo_messaging.Notifier(transport, retry=5)
|
||||
|
||||
self.assertEqual(5, notifier.retry)
|
||||
|
||||
|
||||
class TestRoutingNotifier(test_utils.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestRoutingNotifier, self).setUp()
|
||||
@ -603,9 +628,9 @@ group_1:
|
||||
self.notifier.info({}, 'my_event', {})
|
||||
self.assertFalse(bar_driver.info.called)
|
||||
rpc_driver.notify.assert_called_once_with(
|
||||
{}, mock.ANY, 'INFO', None)
|
||||
{}, mock.ANY, 'INFO', -1)
|
||||
rpc2_driver.notify.assert_called_once_with(
|
||||
{}, mock.ANY, 'INFO', None)
|
||||
{}, mock.ANY, 'INFO', -1)
|
||||
|
||||
|
||||
class TestNoOpNotifier(test_utils.BaseTestCase):
|
||||
|
8
releasenotes/notes/retry-support-07996ef04dda9482.yaml
Normal file
8
releasenotes/notes/retry-support-07996ef04dda9482.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
| Retry support for oslo_messaging_notifications driver
|
||||
| Configuration param 'retry' is added. Default is -1, indefinite
|
||||
|
||||
* *retry* (default=-1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user