Fix requeue process on event handling error
The NotificationDispatcher in oslo_messaging is able to requeue notifications which cannot be successfully handled by endpoint. That need endpoint return a 'requeue' if exception happened on handling. In EventsNotificationEndpoint of ceilometer, the return value was always None. Change-Id: Iab10ca06766e1454d1d2338e72087b6bca7590b6 Closes-Bug: #1489431
This commit is contained in:
parent
fcf5b4e7e2
commit
c197f4793d
@ -50,7 +50,7 @@ class EventsNotificationEndpoint(object):
|
||||
# source of the notification. This will have to get added back later.
|
||||
notification = messaging.convert_to_old_notification_format(
|
||||
'info', ctxt, publisher_id, event_type, payload, metadata)
|
||||
self.process_notification(notification)
|
||||
return self.process_notification(notification)
|
||||
|
||||
def error(self, ctxt, publisher_id, event_type, payload, metadata):
|
||||
"""Convert error message to Ceilometer Event.
|
||||
@ -67,7 +67,7 @@ class EventsNotificationEndpoint(object):
|
||||
# source of the notification. This will have to get added back later.
|
||||
notification = messaging.convert_to_old_notification_format(
|
||||
'error', ctxt, publisher_id, event_type, payload, metadata)
|
||||
self.process_notification(notification)
|
||||
return self.process_notification(notification)
|
||||
|
||||
def process_notification(self, notification):
|
||||
try:
|
||||
|
@ -146,6 +146,16 @@ class TestEventEndpoint(tests_base.BaseTestCase):
|
||||
'compute.instance.create.end',
|
||||
TEST_NOTICE_PAYLOAD, TEST_NOTICE_METADATA)
|
||||
|
||||
def test_bad_event_non_ack_and_requeue(self):
|
||||
self._setup_endpoint(['test://'])
|
||||
self.fake_publisher.publish_events.side_effect = Exception
|
||||
self.CONF.set_override("ack_on_event_error", False,
|
||||
group="notification")
|
||||
ret = self.endpoint.info(TEST_NOTICE_CTXT, 'compute.vagrant-precise',
|
||||
'compute.instance.create.end',
|
||||
TEST_NOTICE_PAYLOAD, TEST_NOTICE_METADATA)
|
||||
self.assertEqual(oslo_messaging.NotificationResult.REQUEUE, ret)
|
||||
|
||||
def test_message_to_event_bad_event(self):
|
||||
self._setup_endpoint(['test://'])
|
||||
self.fake_publisher.publish_events.side_effect = Exception
|
||||
|
Loading…
Reference in New Issue
Block a user