]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Store and log correct exception info
authorTerry Wilson <twilson@redhat.com>
Wed, 25 Mar 2015 02:59:44 +0000 (21:59 -0500)
committerTerry Wilson <twilson@redhat.com>
Fri, 27 Mar 2015 10:23:48 +0000 (05:23 -0500)
Since OVSDB commands execute in a different thread, the exceptions
that are passed to the original thread do not contain traceback
info from the exception. This patch stores the text from the
exception as it is caught so that the calling thread can log it.

Change-Id: If462c3d5dc104b349218dc910aa281220a5af528

neutron/agent/ovsdb/impl_idl.py
neutron/agent/ovsdb/native/connection.py
neutron/agent/ovsdb/native/idlutils.py

index 39a010cdaf5f9777a51675a9bb355b1a7272d404..5a482422b7820aae39657597278ddbe542370043 100644 (file)
@@ -64,8 +64,11 @@ class Transaction(api.Transaction):
     def commit(self):
         ovsdb_connection.queue_txn(self)
         result = self.results.get()
-        if isinstance(result, Exception) and self.check_error:
-            raise result
+        if self.check_error:
+            if isinstance(result, idlutils.ExceptionResult):
+                if self.log_errors:
+                    LOG.error(result.tb)
+                raise result.ex
         return result
 
     def do_commit(self):
index 25ea55ead51ab184b4af9b405225074e0542c920..22b42ff3864bd27da0d1662b0c256cd6d72e2010 100644 (file)
@@ -15,6 +15,7 @@
 import os
 import Queue
 import threading
+import traceback
 
 from ovs.db import idl
 from ovs import poller
@@ -80,7 +81,9 @@ class Connection(object):
                 try:
                     txn.results.put(txn.do_commit())
                 except Exception as ex:
-                    txn.results.put(ex)
+                    er = idlutils.ExceptionResult(ex=ex,
+                                                  tb=traceback.format_exc())
+                    txn.results.put(er)
                 self.txns.task_done()
 
     def queue_txn(self, txn):
index 89f322453959790e367171387f62442ae2dbb058..1c260009d97b01516f80abfd44a0ccab3042fe2a 100644 (file)
@@ -21,6 +21,12 @@ from ovs import poller
 from ovs import stream
 
 
+class ExceptionResult(object):
+    def __init__(self, ex, tb):
+        self.ex = ex
+        self.tb = tb
+
+
 def get_schema_helper(connection):
     err, strm = stream.Stream.open_block(
         stream.Stream.open(connection))