Add missing transaction in driver_controller.

All the operations related to router associations (add/del)
were executed under transactions, there was a case
'get_provider_for_router' doing add_resource_association
out of db transaction, luckily due to autocommit there were no
issues but this patch adds the missing transaction.

Closes-Bug: #1778118

Change-Id: Iaec9a40614c7e6ce1120e9fa7ef3a4fdb4d59963
This commit is contained in:
Manjeet Singh Bhatia 2018-06-21 18:17:41 +00:00
parent b9fabd8267
commit d97cce0403
1 changed files with 9 additions and 6 deletions

View File

@ -180,12 +180,15 @@ class DriverController(object):
router = self.l3_plugin.get_router(context, router_id)
driver = self._attrs_to_driver(router)
driver_name = driver.name
self._stm.add_resource_association(context, plugin_constants.L3,
driver_name, router_id)
registry.notify(
resources.ROUTER_CONTROLLER, events.PRECOMMIT_ADD_ASSOCIATION,
self, context=context, router_id=router_id,
router=router, old_driver=None, new_driver=driver)
with context.session.begin(subtransactions=True):
self._stm.add_resource_association(
context, plugin_constants.L3,
driver_name, router_id)
registry.notify(
resources.ROUTER_CONTROLLER,
events.PRECOMMIT_ADD_ASSOCIATION,
self, context=context, router_id=router_id,
router=router, old_driver=None, new_driver=driver)
return self.drivers[driver_name]
def _get_provider_for_create(self, context, router):