VIRT-2996: Handling malformed notifications sent by Nova to stacktach.

Before:- Stacktack threw an exception and was unable to log the message. It later tries to process the same erroneous notification repeatedly.
After: Stacktach catched the malformed notification and logs the message. It later acknowledges RabbiMQ so that the message is removed from queue.

Change-Id: I7a33816a7ce4660513b047a7e54c3223a63c8cb3
This commit is contained in:
Isham Ibrahim 2017-05-30 15:56:57 +05:30
parent 0c4b90f1c3
commit a80b25fcce
1 changed files with 7 additions and 2 deletions

View File

@ -143,9 +143,14 @@ class Consumer(kombu.mixins.ConsumerMixin):
def on_nova(self, body, message):
try:
self._process(message)
except ValueError, e:
_get_child_logger().error("Error: %s\nMalformed message body found : \n%s" %
(e, str(message.body)))
# Mark message as read to avoid re-reading the malformed message.
message.ack()
except Exception, e:
_get_child_logger().debug("Problem: %s\nFailed message body:\n%s" %
(e, json.loads(str(message.body))))
_get_child_logger().error("Problem: %s\nFailed message body:\n%s" %
(e, str(message.body)))
raise
def _shutdown(self, signal, stackframe = False):