Move router gateway deletion out of transaction
Router gateway delete includes callback notification with AFTER_DELETE event. Callback manager does not expect it to be called inside transaction and suppresses retriable DB errors. As a result it may return with inactive DB session. Router gw deletion was out of transaction before new engine facade switch. IMO gw absence is still a valid state for a router that eventually failed to be deleted for some reason. Change-Id: Iba868be4d6da4d5ed12effd6705771e9a798a677 Closes-Bug: #1915271
This commit is contained in:
parent
4a021306ad
commit
3c40956166
|
@ -517,15 +517,18 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||||
registry.publish(resources.ROUTER, events.BEFORE_DELETE, self,
|
registry.publish(resources.ROUTER, events.BEFORE_DELETE, self,
|
||||||
payload=events.DBEventPayload(
|
payload=events.DBEventPayload(
|
||||||
context, resource_id=id))
|
context, resource_id=id))
|
||||||
|
|
||||||
# TODO(nati) Refactor here when we have router insertion model
|
# TODO(nati) Refactor here when we have router insertion model
|
||||||
with db_api.CONTEXT_WRITER.using(context):
|
with db_api.CONTEXT_READER.using(context):
|
||||||
router = self._ensure_router_not_in_use(context, id)
|
router = self._ensure_router_not_in_use(context, id)
|
||||||
original = self._make_router_dict(router)
|
original = self._make_router_dict(router)
|
||||||
self._delete_current_gw_port(context, id, router, None)
|
self._delete_current_gw_port(context, id, router, None)
|
||||||
|
|
||||||
|
with db_api.CONTEXT_WRITER.using(context):
|
||||||
# TODO(ralonsoh): move this section (port deletion) out of the DB
|
# TODO(ralonsoh): move this section (port deletion) out of the DB
|
||||||
# transaction.
|
# transaction.
|
||||||
router_ports_ids = (rp.port.id for rp in router.attached_ports)
|
router_ports_ids = (rp.port_id for rp in
|
||||||
|
l3_obj.RouterPort.get_objects(context, router_id=id))
|
||||||
if context.session.is_active:
|
if context.session.is_active:
|
||||||
context.GUARD_TRANSACTION = False
|
context.GUARD_TRANSACTION = False
|
||||||
for rp_id in router_ports_ids:
|
for rp_id in router_ports_ids:
|
||||||
|
|
Loading…
Reference in New Issue