remove context_manager from neutron

The context_manager is already in neutron-lib and being used by our
active consumers either directly or via the current shim we have
in neutron.db.api.context_manager that just references that in lib.
This patch removes the context_manager from neutron and updates the UTs
that mock it.

NeutronLibImpact

Change-Id: Ia5191a71b377e2862592a09da8dc3a5d415de9aa
This commit is contained in:
Boden R 2018-11-30 13:29:08 -07:00
parent 7518ac5cfa
commit aa88be0689
3 changed files with 4 additions and 7 deletions

View File

@ -15,16 +15,12 @@
import weakref
from neutron_lib.db import api
from neutron_lib.db import model_base
import sqlalchemy
from sqlalchemy import event # noqa
from sqlalchemy import orm
context_manager = api.get_context_manager()
# Expire relationships when foreign key changes.
#
# NOTE(ihrachys) Arguably, it's a sqlalchemy anti-pattern to access child

View File

@ -21,6 +21,7 @@ from neutron_lib.callbacks import events
from neutron_lib.callbacks import registry
from neutron_lib.callbacks import resources
from neutron_lib import context
from neutron_lib.db import api as session
from neutron_lib.plugins import directory
from neutron_lib import worker as neutron_worker
from oslo_concurrency import processutils
@ -36,7 +37,6 @@ from neutron.common import config
from neutron.common import profiler
from neutron.common import rpc as n_rpc
from neutron.conf import service
from neutron.db import api as session
from neutron import wsgi
@ -244,7 +244,7 @@ def _start_workers(workers):
# dispose the whole pool before os.fork, otherwise there will
# be shared DB connections in child processes which may cause
# DB errors.
session.context_manager.dispose_pool()
session.get_context_manager().dispose_pool()
for worker in process_workers:
worker_launcher.launch_service(worker,

View File

@ -18,6 +18,7 @@ import socket
import ssl
import mock
from neutron_lib.db import api as db_api
from neutron_lib import exceptions as exception
from oslo_config import cfg
from six.moves import urllib
@ -68,7 +69,7 @@ class TestServiceBase(base.BaseTestCase):
class TestWorkerService(TestServiceBase):
"""WorkerService tests."""
@mock.patch('neutron.db.api.context_manager.get_legacy_facade')
@mock.patch.object(db_api, 'get_context_manager')
def test_start_withoutdb_call(self, apimock):
_service = mock.Mock()
_service.pool.spawn.return_value = None