Cleanup port: perform backend operation before DB operation

Invert the order of operation in order to ensure DB entry is not
removed is operations fails in unexpected way

Change-Id: I77c1a48ac59ab577ed284d40e2a90fc44fe32b10
This commit is contained in:
Salvatore Orlando 2021-11-28 10:11:35 -08:00
parent a6764b97bc
commit 52a975fffe

View File

@ -1996,11 +1996,17 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
dhcp_opts=dhcp_opts, subnet=subnet) dhcp_opts=dhcp_opts, subnet=subnet)
def _cleanup_port(self, context, port_id, nsx_port_id=None): def _cleanup_port(self, context, port_id, nsx_port_id=None):
# Clean up neutron port and nsx manager port if provided # Clean up neutro nsx manager port if provided and then
# neutron port.
# Does not handle cleanup of policy port # Does not handle cleanup of policy port
try:
if nsx_port_id and self.nsxlib:
self.nsxlib.logical_port.delete(nsx_port_id)
except nsx_lib_exc.ResourceNotFound:
LOG.info("NSX Port %s for neutron port %s was not found during "
"cleanuo. Probably already deleted",
port_id, nsx_port_id)
super(NsxPluginV3Base, self).delete_port(context, port_id) super(NsxPluginV3Base, self).delete_port(context, port_id)
if nsx_port_id and self.nsxlib:
self.nsxlib.logical_port.delete(nsx_port_id)
def _is_excluded_port(self, device_owner, port_security): def _is_excluded_port(self, device_owner, port_security):
if device_owner == l3_db.DEVICE_OWNER_ROUTER_INTF: if device_owner == l3_db.DEVICE_OWNER_ROUTER_INTF: