Producing useless traceback info

Bug #726742 reported by Rick Harris
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Medium
Rick Harris

Bug Description

In some cases, the exceptions Glance is raising are next to useless because the traceback information was lost. The reason this is happening is that we're doing:

except Exception, e:
  # do something that invokes eventlet
  raise e

The `raise e` syntax doesn't re-raise in the same context as the original exception. To work around this we can do something like:

        except Exception, e:
            # NOTE(sirp): _safe_kill uses httplib which, in turn, uses
            # Eventlet's GreenSocket. Eventlet subsequently clears exceptions
            # by calling `sys.exc_clear()`.
            # To work around this, we memorize the exception context, and then re-raise in 3-arg form after running the eventlet related code
            exc_type, exc_value, exc_traceback = sys.exc_info()
            self._safe_kill(req, image_meta)
            raise exc_type, exc_value, exc_traceback

Related branches

Revision history for this message
Brian Lamar (blamar) wrote :

Hey Rick, would a blank raise do the same thing for you?

except Exception:
    self._safe_kill(req, image_meta)
    raise

should raise the original exception in the original context.

Changed in glance:
assignee: nobody → Rick Harris (rconradharris)
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
Rick Harris (rconradharris) wrote :

> should raise the original exception in the original context.

That's generally true. However, that doesn't work in this case. The reason is because, we're calling out to _safe_kill in the exception handler, which in term invokes eventlet code. This has the effect of calling `sys.exc_clear()` which destroys the 'memorized' exception information, preventing a no-arg-raise from working.

To work around this, we have manually 'memorize' the exception context.

We only need to use this hack in cases where the exception handler triggers eventlet code and we want to re-raise the current exception.

Revision history for this message
Brian Lamar (blamar) wrote :

Absolutely right. Serves me right for not reading the comments :)

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in glance:
milestone: none → 2011.2
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.