From 2756d9efe08d7cc1f1b244ce72b23007834d9b4f Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Tue, 24 Mar 2015 21:59:44 -0500 Subject: [PATCH] Store and log correct exception info 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 | 7 +++++-- neutron/agent/ovsdb/native/connection.py | 5 ++++- neutron/agent/ovsdb/native/idlutils.py | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/neutron/agent/ovsdb/impl_idl.py b/neutron/agent/ovsdb/impl_idl.py index 39a010cda..5a482422b 100644 --- a/neutron/agent/ovsdb/impl_idl.py +++ b/neutron/agent/ovsdb/impl_idl.py @@ -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): diff --git a/neutron/agent/ovsdb/native/connection.py b/neutron/agent/ovsdb/native/connection.py index 25ea55ead..22b42ff38 100644 --- a/neutron/agent/ovsdb/native/connection.py +++ b/neutron/agent/ovsdb/native/connection.py @@ -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): diff --git a/neutron/agent/ovsdb/native/idlutils.py b/neutron/agent/ovsdb/native/idlutils.py index 89f322453..1c260009d 100644 --- a/neutron/agent/ovsdb/native/idlutils.py +++ b/neutron/agent/ovsdb/native/idlutils.py @@ -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)) -- 2.45.2