From 445551ee321c69dfdeccfc62a3dc5615d826259d Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Tue, 9 Jan 2018 14:21:35 -0800 Subject: [PATCH] Revert "Use writer for trunk database operations" This reverts commit bd9e6467d70744dea624387ef2435de658ec6611. Since trunk plugin uses OVO objects that still use the old engine facade, and as we learnt in bug 1706750, old and new facades don't cooperate, we risk some objects being committed to database before writer.using __exit__s, or even when writer.using fails with an exception, because old facade will commit changes to database right after its session.begin context manager __exit__s. Reverting the switch to new facade for trunk plugin until we figure out how to switch OVO layer to the new facade. Partially-Implements: blueprint enginefacade-switch Change-Id: I2918c15f6c9ea71b1e51797e5ba9c835505579e0 --- neutron/services/trunk/plugin.py | 10 +++++----- neutron/services/trunk/rpc/server.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/neutron/services/trunk/plugin.py b/neutron/services/trunk/plugin.py index 416ac8b1f1c..e6d3e42d1c9 100644 --- a/neutron/services/trunk/plugin.py +++ b/neutron/services/trunk/plugin.py @@ -221,7 +221,7 @@ class TrunkPlugin(service_base.ServicePluginBase, port_id=trunk['port_id'], status=constants.DOWN_STATUS, sub_ports=sub_ports) - with db_api.context_manager.writer.using(context): + with db_api.autonested_transaction(context.session): trunk_obj.create() payload = callbacks.TrunkPayload(context, trunk_obj.id, current_trunk=trunk_obj) @@ -236,7 +236,7 @@ class TrunkPlugin(service_base.ServicePluginBase, def update_trunk(self, context, trunk_id, trunk): """Update information for the specified trunk.""" trunk_data = trunk['trunk'] - with db_api.context_manager.writer.using(context): + with db_api.autonested_transaction(context.session): trunk_obj = self._get_trunk(context, trunk_id) original_trunk = copy.deepcopy(trunk_obj) # NOTE(status_police): a trunk status should not change during an @@ -256,7 +256,7 @@ class TrunkPlugin(service_base.ServicePluginBase, def delete_trunk(self, context, trunk_id): """Delete the specified trunk.""" - with db_api.context_manager.writer.using(context): + with db_api.autonested_transaction(context.session): trunk = self._get_trunk(context, trunk_id) rules.trunk_can_be_managed(context, trunk) trunk_port_validator = rules.TrunkPortValidator(trunk.port_id) @@ -278,7 +278,7 @@ class TrunkPlugin(service_base.ServicePluginBase, @db_base_plugin_common.convert_result_to_dict def add_subports(self, context, trunk_id, subports): """Add one or more subports to trunk.""" - with db_api.context_manager.writer.using(context): + with db_api.autonested_transaction(context.session): trunk = self._get_trunk(context, trunk_id) # Check for basic validation since the request body here is not @@ -332,7 +332,7 @@ class TrunkPlugin(service_base.ServicePluginBase, def remove_subports(self, context, trunk_id, subports): """Remove one or more subports from trunk.""" subports = subports['sub_ports'] - with db_api.context_manager.writer.using(context): + with db_api.autonested_transaction(context.session): trunk = self._get_trunk(context, trunk_id) original_trunk = copy.deepcopy(trunk) rules.trunk_can_be_managed(context, trunk) diff --git a/neutron/services/trunk/rpc/server.py b/neutron/services/trunk/rpc/server.py index d4297f8ae3b..1da96befff5 100644 --- a/neutron/services/trunk/rpc/server.py +++ b/neutron/services/trunk/rpc/server.py @@ -103,7 +103,7 @@ class TrunkSkeleton(object): def update_trunk_status(self, context, trunk_id, status): """Update the trunk status to reflect outcome of data plane wiring.""" - with db_api.context_manager.writer.using(context): + with db_api.autonested_transaction(context.session): trunk = trunk_objects.Trunk.get_object(context, id=trunk_id) if trunk: trunk.update(status=status)