From c197f4793d3f2cb6ed37f6b8fe25a9e849665397 Mon Sep 17 00:00:00 2001 From: liu-sheng Date: Thu, 27 Aug 2015 19:54:42 +0800 Subject: [PATCH] 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 --- ceilometer/event/endpoint.py | 4 ++-- ceilometer/tests/unit/event/test_endpoint.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ceilometer/event/endpoint.py b/ceilometer/event/endpoint.py index 44977d67..ed10b722 100644 --- a/ceilometer/event/endpoint.py +++ b/ceilometer/event/endpoint.py @@ -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: diff --git a/ceilometer/tests/unit/event/test_endpoint.py b/ceilometer/tests/unit/event/test_endpoint.py index e16adc8b..613f8b8c 100644 --- a/ceilometer/tests/unit/event/test_endpoint.py +++ b/ceilometer/tests/unit/event/test_endpoint.py @@ -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