← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1500896] Re: It's not necessary to pass context as kwarg to oslo.log in most cases

 

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

commit b3d58ed718db91015582cf759a7c8af1874ef093
Author: Sivasathurappan Radhakrishnan <siva.radhakrishnan@xxxxxxxxx>
Date:   Mon May 16 22:09:44 2016 +0000

    Remove context object in oslo.log method
    
    Removed context object while logging as Nova uses oslo.context's
    RequestContext which means the context object is in scope when doing
    logging. Added hack to notify, in case if someone uses it in logging
    statements in future.
    
    Change-Id: I5aaa869f2e6155964827e659d18e2bcaad9d866b
    Closes-Bug:#1500896


** 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/1500896

Title:
  It's not necessary to pass context as kwarg to oslo.log in most cases

Status in Cinder:
  Fix Released
Status in OpenStack Compute (nova):
  Fix Released

Bug description:
  Nova is using oslo.context's RequestContext which means the context
  object is in scope when doing logging using oslo.log:

  http://docs.openstack.org/developer/oslo.log/usage.html#passing-
  context

  But there are a lot of places in nova where we do something like:

          context = context.elevated()
          LOG.info(_LI("Rebooting instance"), context=context, instance=instance)

  This is confusing because it makes you wonder if (1) you should be
  passing context in logging method and (2) if it's OK to pass the
  elevated context in this case or if you should be passing the original
  context.

  It turns out that in this case neither is necessary.  The elevated
  context just has the admin flag set, the request / user / project IDs
  in the context are left unchanged, which is what we want for logging.
  And the context is already in scope because of:

  http://git.openstack.org/cgit/openstack/oslo.context/tree/oslo_context/context.py#n71

  So we don't need to pass it as a kwarg.

  This bug is meant to scrub through nova and remove any unnecessary
  passing of the context object to oslo.log methods.

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


References