start recording error notifications

projects (specifically nova) send notifications on error topic when
an error occurs. we should capture this in events.

Change-Id: Ic42cbce948b8b409f83934146407b2480602921d
Closes-Bug: #1364708
This commit is contained in:
gordon chung 2015-02-05 15:27:38 -05:00
parent 926f781096
commit f7ed2c2a16
2 changed files with 33 additions and 0 deletions

View File

@ -58,6 +58,23 @@ class EventsNotificationEndpoint(object):
'info', ctxt, publisher_id, event_type, payload, metadata)
self.process_notification(notification)
def error(self, ctxt, publisher_id, event_type, payload, metadata):
"""Convert error message to Ceilometer Event.
:param ctxt: oslo.messaging context
:param publisher_id: publisher of the notification
:param event_type: type of notification
:param payload: notification payload
:param metadata: metadata about the notification
"""
# NOTE: the rpc layer currently rips out the notification
# delivery_info, which is critical to determining the
# 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)
def process_notification(self, notification):
try:
event = self.event_converter.to_event(notification)

View File

@ -240,6 +240,22 @@ class TestRealNotification(BaseRealNotification):
fake_publisher_cls.return_value = self.publisher
self._check_notification_service()
@mock.patch('ceilometer.publisher.test.TestPublisher')
def test_notification_service_error_topic(self, fake_publisher_cls):
fake_publisher_cls.return_value = self.publisher
self.srv.start()
notifier = messaging.get_notifier(self.transport,
'compute.vagrant-precise')
notifier.error(context.RequestContext(), 'compute.instance.error',
TEST_NOTICE_PAYLOAD)
start = timeutils.utcnow()
while timeutils.delta_seconds(start, timeutils.utcnow()) < 600:
if len(self.publisher.events) >= self.expected_events:
break
eventlet.sleep(0)
self.srv.stop()
self.assertEqual(self.expected_events, len(self.publisher.events))
@mock.patch('ceilometer.coordination.PartitionCoordinator')
@mock.patch('ceilometer.publisher.test.TestPublisher')
def test_ha_configured_agent_coord_disabled(self, fake_publisher_cls,