Prevent failures on router delete
If a logical router has been removed from the backend, and the DB is an inconsistent state where no NSX mapping is stored for the neutron logical router, the backend will fail when attempting deletion of the router, causing the neutron operation to return a 500. This patch ensures the neutron operation completes successfully, thus reconciling Neutron's DB with the NSX backend. Change-Id: Ieb86faa9a71317fe82da4ea2f473164d01a36910
This commit is contained in:
parent
4a18fb82a4
commit
77d7588553
|
@ -1595,16 +1595,25 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||
context.session, self.cluster, router_id)
|
||||
# It is safe to remove the router from the database, so remove it
|
||||
# from the backend
|
||||
try:
|
||||
self._delete_lrouter(context, router_id, nsx_router_id)
|
||||
except n_exc.NotFound:
|
||||
# This is not a fatal error, but needs to be logged
|
||||
LOG.warning(_LW("Logical router '%s' not found "
|
||||
if nsx_router_id:
|
||||
try:
|
||||
self._delete_lrouter(context, router_id, nsx_router_id)
|
||||
except n_exc.NotFound:
|
||||
# This is not a fatal error, but needs to be logged
|
||||
LOG.warning(_LW("Logical router '%s' not found "
|
||||
"on NSX Platform"), router_id)
|
||||
except api_exc.NsxApiException:
|
||||
raise nsx_exc.NsxPluginException(
|
||||
err_msg=(_("Unable to delete logical router '%s' "
|
||||
"on NSX Platform") % nsx_router_id))
|
||||
else:
|
||||
# If no mapping is found it is likely that the logical router does
|
||||
# not exist anymore in the backend. This is not a fatal condition,
|
||||
# but will result in an exception is "None" is passed to
|
||||
# _delete_lrouter
|
||||
LOG.warning(_LW("No mapping found for logical router '%s' "
|
||||
"on NSX Platform"), router_id)
|
||||
except api_exc.NsxApiException:
|
||||
raise nsx_exc.NsxPluginException(
|
||||
err_msg=(_("Unable to delete logical router '%s' "
|
||||
"on NSX Platform") % nsx_router_id))
|
||||
|
||||
# Remove the NSX mapping first in order to ensure a mapping to
|
||||
# a non-existent NSX router is not left in the DB in case of
|
||||
# failure while removing the router from the neutron DB
|
||||
|
|
Loading…
Reference in New Issue