Added warning when invalid payload is encountered while saving exists notification
This commit is contained in:
parent
0e21b29a03
commit
5d65e5bad7
@ -159,6 +159,8 @@ class GlanceNotification(Notification):
|
||||
utils.str_time_to_unix(audit_period_ending)
|
||||
images = self.payload.get('images', [])
|
||||
else:
|
||||
stacklog.warn("Received exists with invalid payload "
|
||||
"GlanceRawData(%s)" % raw.id)
|
||||
audit_period_beginning = None
|
||||
audit_period_ending = None
|
||||
images = []
|
||||
@ -169,8 +171,8 @@ class GlanceNotification(Notification):
|
||||
uuid = image['id']
|
||||
deleted_at = image['deleted_at']
|
||||
deleted_at = deleted_at and utils.str_time_to_unix(deleted_at)
|
||||
if created_at:
|
||||
|
||||
if created_at:
|
||||
values = {
|
||||
'uuid': uuid,
|
||||
'audit_period_beginning': audit_period_beginning,
|
||||
|
@ -675,3 +675,23 @@ class GlanceExistsNotificationTestCase(StacktachBaseTestCase):
|
||||
json_body)
|
||||
notification.save_exists(raw)
|
||||
self.mox.VerifyAll()
|
||||
|
||||
def test_save_exists_should_log_warning_when_payload_is_invalid(self):
|
||||
raw = self.mox.CreateMockAnything()
|
||||
raw.id = 1
|
||||
body = {
|
||||
"event_type": "image.exists",
|
||||
"publisher_id": "glance-api01-r2961.global.preprod-ord.ohthree.com",
|
||||
"payload": []
|
||||
}
|
||||
deployment = "1"
|
||||
routing_key = "glance_monitor.info"
|
||||
json_body = json.dumps([routing_key, body])
|
||||
self.mox.StubOutWithMock(stacklog, 'warn')
|
||||
stacklog.warn("Received exists with invalid payload GlanceRawData(1)")
|
||||
self.mox.ReplayAll()
|
||||
|
||||
notification = GlanceNotification(body, deployment, routing_key,
|
||||
json_body)
|
||||
notification.save_exists(raw)
|
||||
self.mox.VerifyAll()
|
||||
|
Loading…
x
Reference in New Issue
Block a user