From d055dec0faa1d1bc22d86c808a8633e7b5cbd196 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 6 Oct 2021 02:46:05 -0700 Subject: [PATCH] [NSX-P] Don't cache empty logical switch id for segment If a NSX-T segment is not realized, the plugin will currently return a null value for the corresponding logical switch id. This leads nova to boot VMs with an incorrect network attachment. This change ensures the null value is not cached for the neutron network. Change-Id: I7ef3fc8e13777e5fcdc53bd84d5dc235f7e8686c --- vmware_nsx/plugins/nsx_p/plugin.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vmware_nsx/plugins/nsx_p/plugin.py b/vmware_nsx/plugins/nsx_p/plugin.py index 159bbce028..1599f656a4 100644 --- a/vmware_nsx/plugins/nsx_p/plugin.py +++ b/vmware_nsx/plugins/nsx_p/plugin.py @@ -1724,12 +1724,14 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base): try: nsx_id = self.nsxpolicy.segment.get_realized_logical_switch_id( segment_id) - # Add result to caches - NET_NEUTRON_2_NSX_ID_CACHE[network_id] = nsx_id - NET_NSX_2_NEUTRON_ID_CACHE[nsx_id] = network_id + # Add result to caches - never cache an empty nsx_id + if nsx_id: + NET_NEUTRON_2_NSX_ID_CACHE[network_id] = nsx_id + NET_NSX_2_NEUTRON_ID_CACHE[nsx_id] = network_id return nsx_id except nsx_lib_exc.ManagerError: - LOG.error("Network %s was not realized", network_id) + LOG.error("Network %s was not realized. Cannot fetch " + "logical switch for segment", network_id) # Do not cache this result else: # Add empty result to cache