← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 2017784] [NEW] Incorrect use of "db_api.CONTEXT_*" decorators

 

Public bug reported:

The ``CONTEXT_READER`` and ``CONTEXT_WRITER`` decorators inherit from
``_TransactionContextManager`` [1]. The decorator class call retrieves
the context object from the *args or **kwargs. This decorator is
expecting the "context" object to be the first of the positional
parameters, except if the method belongs to a class where the first
parameter will be "self" or "cls" [2].

However, we are using the decorator in some methods that doesn't belong
to a class and where the first parameter is not one these two. For
example [3].

This is being reported in the tempest tests [4] with the message "ORM
session ...".


[1]https://github.com/openstack/oslo.db/blob/a7c03ba9de6f9a98aa5c36a67e1ecfab77acde9a/oslo_db/sqlalchemy/enginefacade.py#L758
[2]https://github.com/openstack/oslo.db/blob/a7c03ba9de6f9a98aa5c36a67e1ecfab77acde9a/oslo_db/sqlalchemy/enginefacade.py#L1007
[3]https://github.com/openstack/neutron/blob/5cd0388eb7cac84fc1aaa425184bf4af67ed0608/neutron/objects/db/api.py#L34
[4]https://paste.opendev.org/show/bKhTJvlywCKjbONAg8QH/

** Affects: neutron
     Importance: High
     Assignee: Rodolfo Alonso (rodolfo-alonso-hernandez)
         Status: In Progress

** Changed in: neutron
   Importance: Undecided => High

** Changed in: neutron
     Assignee: (unassigned) => Rodolfo Alonso (rodolfo-alonso-hernandez)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/2017784

Title:
  Incorrect use of "db_api.CONTEXT_*" decorators

Status in neutron:
  In Progress

Bug description:
  The ``CONTEXT_READER`` and ``CONTEXT_WRITER`` decorators inherit from
  ``_TransactionContextManager`` [1]. The decorator class call retrieves
  the context object from the *args or **kwargs. This decorator is
  expecting the "context" object to be the first of the positional
  parameters, except if the method belongs to a class where the first
  parameter will be "self" or "cls" [2].

  However, we are using the decorator in some methods that doesn't
  belong to a class and where the first parameter is not one these two.
  For example [3].

  This is being reported in the tempest tests [4] with the message "ORM
  session ...".

  
  [1]https://github.com/openstack/oslo.db/blob/a7c03ba9de6f9a98aa5c36a67e1ecfab77acde9a/oslo_db/sqlalchemy/enginefacade.py#L758
  [2]https://github.com/openstack/oslo.db/blob/a7c03ba9de6f9a98aa5c36a67e1ecfab77acde9a/oslo_db/sqlalchemy/enginefacade.py#L1007
  [3]https://github.com/openstack/neutron/blob/5cd0388eb7cac84fc1aaa425184bf4af67ed0608/neutron/objects/db/api.py#L34
  [4]https://paste.opendev.org/show/bKhTJvlywCKjbONAg8QH/

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



Follow ups