← 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/351495
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=1a495922edf2ac3b18bfddce0b88dc52fec24e43
Submitter: Jenkins
Branch:    master

commit 1a495922edf2ac3b18bfddce0b88dc52fec24e43
Author: bhagyashris <bhagyashri.shewale@xxxxxxxxxxx>
Date:   Wed Aug 3 19:41:51 2016 +0530

    Remove context object in oslo.log method
    
    Removed context object while logging as Cinder uses oslo.context's
    RequestContext which means the context object is in scope when doing
    logging.
    
    Change-Id: I7cc434ad10967596f8354775399e0c6c92ab5570
    Closes-Bug:#1500896


** Changed in: cinder
       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):
  In Progress

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