Commit Graph

5 Commits

Author SHA1 Message Date
Boden R d034df15a1 remove common db alaises to db utils
A handful of the functions implemented in neutron.db._utils are exposed
in common_db_mixin as aliases. These are unneeded as they're already
defined elsewhere.

This patch removes the following aliases in common_db_mixin:
- safe_creation
- model_query_scope
- model_query
- resource_fields

It also renames the UT for common db mixin to
test__utils to reflect the fact that its testing functions
from the _utils db module.

NeutronLibImpact

Change-Id: I53cd533f107d950f163ad5b19b47097546a4691d
2018-05-01 14:13:24 -06:00
Armando Migliaccio ca751a1486 Spin off context module
NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I48cf45dc1b07035d952152eac2548a3bd9fc2832
2017-03-06 16:25:29 +00:00
Henry Gessau 8f80a52b01 Refactor/prepare db common utils for neutron-lib
Extract all the common utils from common_db_mixin.py in preparation
for moving them to neutron-lib.

This is a preliminary step in preparation for refactoring the
CommonDbMixin class and moving it to neutron-lib also.

Partial Blueprint: neutron-lib

Change-Id: I3cba375a8162cb68e8f988f22f5c8b1ce7915180
2016-10-28 10:53:11 -04:00
Kevin Benton d1c501cd1d L3HA: Do not wrap create/delete in transaction
This is unsafe when calling ML2 because ML2 assumes that its
functions will not be called inside of a transaction. This is
not only an issue for drivers that try to do DB lookups using
a different session in the post commit operation, but it's a
big issue for the delete methods.

The delete subnet and network methods in ML2 have 'while True'
loops that catch concurrency errors and retry the operation after
looking up info. If these are called inside a transaction, the
lookups will contain stale information and it can lead to the
while True loop never terminating!

Closes-Bug: #1551958
Change-Id: I33dc084ed15e5491fdda19da712a746ca87fbc8c
2016-03-11 23:59:10 +00:00
Ann Kamyshnikova 924f19e8f1 Make object creation methods in l3_hamode_db atomic
Methods _create_ha_network, add_ha_port don't have wrapping
transaction in them, so they are prone to race conditions.
This commit adds a transaction to them. To avoid problem with
rolling back outmost transaction during exception handling,
internal methods have been wrapped in nested transaction.

Nested transaction is required in places like this:

def create():
      create_something()
      try:
            _do_other_thing()
      except Exception:
             with excutils.save_and_reraise_exception():
                     delete_something()

def _do_other_thing():
     with context.session.begin(subtransactions=True):
         ....

When exception is raised in _do_other_thing it
is caught in except block, but the object cannot be deleted in
except section because internal transaction has been rolled back.

A new method safe_creation and has been added
that provides a common way of handling such situations.

Closes-bug: #1501686

Change-Id: I952f6f7f8684743aa7f829bd92b1dc41b2c6aecf
2016-01-18 13:36:39 +03:00