← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1525282] Re: wrap_exception decorator does not grab arguments properly for decorated methods

 

Reviewed:  https://review.openstack.org/256118
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=1b757c328d43d8154282794fddb8822ea265b1cf
Submitter: Jenkins
Branch:    master

commit 1b757c328d43d8154282794fddb8822ea265b1cf
Author: Andrew Laski <andrew.laski@xxxxxxxxxxxxx>
Date:   Thu Dec 10 17:34:09 2015 -0500

    Fix wrap_exception to get all arguments for payload
    
    The wrap_exception decorator that attempts to send a notification when
    exceptions occur was not sending all the arguments it was intending to.
    It relies on getcallargs to get the arguments and argument names for the
    called method but if the method has another decorator on it getcallargs
    pulls information for the decorator rather than the decorated method.
    This pulls the decorated method with get_wrapped_function and then calls
    getcallargs.
    
    get_wrapped_function was moved to safeutils because utils.py can't be
    imported by exception.py without a circular import.
    
    A few tests were updated to include the id on the instance object used.
    This was done because serialization of the object includes the
    instance.name field which assumes that id is set to populate the
    CONF.instance_name_template.  When id is not set it triggers a lazy load
    which fails in the test environment.
    
    Change-Id: I87d8691a2aae6f3555177364f3c40a490a6f7591
    Closes-bug: 1525282


** Changed in: nova
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1525282

Title:
  wrap_exception decorator does not grab arguments properly for
  decorated methods

Status in OpenStack Compute (nova):
  Fix Released

Bug description:
  The wrap_exception decorator, which pulls the wrapped method arguments
  and sends a notification if there is an exception raised from the
  method, is not pulling the full list of arguments.  This is because of
  a combination of relying on safe_utils.getcallargs which doesn't pull
  arguments when the called method uses *args or **kwargs and not using
  get_wrapped_function to get the call args for the decorated method.
  What is currently happening is getcallargs is passed a decorated
  method and pulls the argument list for the decorator, and most
  decorators are defined with *args and **kwargs.  Instead
  get_wrapped_function should be called first and the result should be
  passed to getcallargs.

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1525282/+subscriptions


References