summaryrefslogtreecommitdiffstats
path: root/nova/notifications.py
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2013-03-05 10:55:18 -0500
committerRussell Bryant <rbryant@redhat.com>2013-03-05 10:57:55 -0500
commit2f983793574de07269c4a79852d75a9059465ee0 (patch)
treeb3c007c3f5fc8d45e4e575a6d233e19bcdeffe92 /nova/notifications.py
parentad57a303f1916d99f73eb8123f60c8a2fd1e6a78 (diff)
downloadnova-2f983793574de07269c4a79852d75a9059465ee0.tar.gz
nova-2f983793574de07269c4a79852d75a9059465ee0.tar.xz
nova-2f983793574de07269c4a79852d75a9059465ee0.zip
Fix issues with re-raising exceptions.
There is complication with re-raising exceptions and our usage of eventlet. If the code in the exception handler accesses the db or rpc in the exception handler, it will no longer be able to re-raise the exception. Using excutils.save_and_reraise_exception() works aorund this issue. The most common error is calling LOG.error() or LOG.exception(), as it is possible for these to go access rpc. There is an option to turn on notifications for these errors. Fix bug 845866. Change-Id: Icfca2af63805711229249aa7abe60a938edd1b35
Diffstat (limited to 'nova/notifications.py')
-rw-r--r--nova/notifications.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/nova/notifications.py b/nova/notifications.py
index bed06acf6..16a49dcf6 100644
--- a/nova/notifications.py
+++ b/nova/notifications.py
@@ -26,6 +26,7 @@ from nova import db
from nova.image import glance
from nova import network
from nova.network import model as network_model
+from nova.openstack.common import excutils
from nova.openstack.common import log
from nova.openstack.common.notifier import api as notifier_api
from nova.openstack.common import timeutils
@@ -225,10 +226,14 @@ def bandwidth_usage(instance_ref, audit_start,
nw_info = network.API().get_instance_nw_info(admin_context,
instance_ref)
except Exception:
- LOG.exception(_('Failed to get nw_info'), instance=instance_ref)
- if ignore_missing_network_data:
- return
- raise
+ try:
+ with excutils.save_and_reraise_exception():
+ LOG.exception(_('Failed to get nw_info'),
+ instance=instance_ref)
+ except Exception:
+ if ignore_missing_network_data:
+ return
+ raise
macs = [vif['address'] for vif in nw_info]
uuids = [instance_ref["uuid"]]