Merge lp:~johannes.erdfelt/nova/lp822748 into lp:~hudson-openstack/nova/trunk

Proposed by Johannes Erdfelt
Status: Merged
Approved by: Josh Kearney
Approved revision: 1394
Merged at revision: 1395
Proposed branch: lp:~johannes.erdfelt/nova/lp822748
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 33 lines (+8/-1)
1 file modified
nova/exception.py (+8/-1)
To merge this branch: bzr merge lp:~johannes.erdfelt/nova/lp822748
Reviewer Review Type Date Requested Status
Sandy Walsh (community) Approve
Josh Kearney (community) Approve
Review via email: mp+70774@code.launchpad.net

Description of the change

nova.exception.wrap_exception will re-raise some exceptions, but in the process of possibly notifying that an exception has occurred, it may clobber the current exception information. nova.utils.to_primitive in particular (used by the notifier code) will catch and handle an exception clobbering the current exception being handled in wrap_exception. Eventually when using the bare 'raise', it will attempt to raise None resulting a completely different and unhelpful exception.

The patch saves the exception at the beginning of wrap_exception and then re-raises the original exception avoiding the possibility of a clobbered exception.

To post a comment you must log in.
Revision history for this message
Josh Kearney (jk0) wrote :

LGTM

review: Approve
Revision history for this message
Sandy Walsh (sandy-walsh) wrote :

Ah, I see now what was happening. Good catch.

review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :
Download full text (94.5 KiB)

The attempt to merge lp:~johannes.erdfelt/nova/lp822748 into lp:nova failed. Below is the output from the failed tests.

FloatingIpTest
    test_floating_ip_allocate OK 0.15
    test_floating_ip_associate OK 0.09
    test_floating_ip_disassociate OK 0.10
    test_floating_ip_release OK 0.09
    test_floating_ip_show OK 0.09
    test_floating_ips_list OK 0.08
    test_translate_floating_ip_view OK 0.04
    test_translate_floating_ip_view_dict OK 0.02
FixedIpTest
    test_add_fixed_ip OK 0.20
    test_add_fixed_ip_no_network OK 0.06
    test_remove_fixed_ip OK 0.06
    test_remove_fixed_ip_no_address OK 0.07
AccountsTest
    test_account_create OK 0.16
    test_account_delete OK 0.15
    test_account_update OK 0.32
    test_get_account OK 0.15
AdminAPITest
    test_admin_disabled OK 0.12
    test_admin_enabled OK 0.15
APITest
    test_exceptions_are_converted_to_faults OK 0.01
    test_malformed_json OK 0.05
    test_malformed_xml OK 0.06
Test
    test_authorize_project OK 0.24
    test_authorize_token OK 0.09
    test_authorize_user OK 0.05
    test_bad_project OK 0.10
    test_bad_token OK 0.05
    test_bad_user_bad_key OK 0.06
    test_bad_user_good_key OK 0.06
    test_no_user OK 0.06
    test_not_existing_project OK 0.21
    test_token_expiry OK 0.05
TestFunctional
    test_token_doesnotexist OK 0.06
    test_token_expiry OK 0.08
TestLimiter
    test_authorize_token OK 0.09
LimiterTest
    test_limiter_custom_max_limit OK 0.00
    test_limiter_limit_and_offset OK 0.00
    test_limiter_limit_medium OK 0.00
    test_limiter_limit_over_max OK 0.00
    test_limiter_limit_zero OK 0.00
    test_limiter_negative_limit OK 0.00
    test_limiter_negative_offset ...

lp:~johannes.erdfelt/nova/lp822748 updated
1394. By Johannes Erdfelt

Import sys as well

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/exception.py'
2--- nova/exception.py 2011-08-05 15:59:14 +0000
3+++ nova/exception.py 2011-08-08 19:31:32 +0000
4@@ -25,6 +25,7 @@
5 """
6
7 from functools import wraps
8+import sys
9
10 from nova import log as logging
11
12@@ -96,6 +97,10 @@
13 try:
14 return f(*args, **kw)
15 except Exception, e:
16+ # Save exception since it can be clobbered during processing
17+ # below before we can re-raise
18+ exc_info = sys.exc_info()
19+
20 if notifier:
21 payload = dict(args=args, exception=e)
22 payload.update(kw)
23@@ -122,7 +127,9 @@
24 LOG.exception(_('Uncaught exception'))
25 #logging.error(traceback.extract_stack(exc_traceback))
26 raise Error(str(e))
27- raise
28+
29+ # re-raise original exception since it may have been clobbered
30+ raise exc_info[0], exc_info[1], exc_info[2]
31
32 return wraps(f)(wrapped)
33 return inner