From 67f4665605f109f071d66ddb7894d678a2fd1c3a Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Sun, 28 Nov 2021 10:11:35 -0800 Subject: [PATCH] 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 --- vmware_nsx/plugins/common_v3/plugin.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vmware_nsx/plugins/common_v3/plugin.py b/vmware_nsx/plugins/common_v3/plugin.py index 7fc0a15938..7fa9e1322b 100644 --- a/vmware_nsx/plugins/common_v3/plugin.py +++ b/vmware_nsx/plugins/common_v3/plugin.py @@ -2000,11 +2000,17 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, dhcp_opts=dhcp_opts, subnet=subnet) 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 + 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) - if nsx_port_id and self.nsxlib: - self.nsxlib.logical_port.delete(nsx_port_id) def _is_excluded_port(self, device_owner, port_security): if device_owner == l3_db.DEVICE_OWNER_ROUTER_INTF: