[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
This commit is contained in:
Salvatore Orlando 2021-10-06 02:46:05 -07:00 committed by Salvatore Orlando
parent 6184264d39
commit 2ff3327566
1 changed files with 6 additions and 4 deletions

View File

@ -1737,12 +1737,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