Merge "Fix KeyError failure in _sync_subnet_dhcp_options()"
This commit is contained in:
commit
4cad0eda59
@ -870,10 +870,20 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
|
||||
LOG.warning('DHCP options for subnet %s present in '
|
||||
'Neutron but out of sync with OVN NB DB', subnet_id)
|
||||
if self.mode == SYNC_MODE_REPAIR:
|
||||
# If neutron-server is running we could race and find a
|
||||
# subnet without a cached network, just skip it to avoid
|
||||
# a KeyError below.
|
||||
network_id = utils.ovn_name(subnet['network_id'])
|
||||
if network_id not in db_networks:
|
||||
LOG.warning('Network %s for subnet %s not found in OVN NB '
|
||||
'DB network cache, possible race condition, '
|
||||
'please check that neutron-server is stopped! '
|
||||
'Skipping subnet.', network_id, subnet_id)
|
||||
continue
|
||||
try:
|
||||
LOG.warning('Adding/Updating DHCP options for subnet %s '
|
||||
'in OVN NB DB', subnet_id)
|
||||
network = db_networks[utils.ovn_name(subnet['network_id'])]
|
||||
network = db_networks[network_id]
|
||||
# _ovn_client._add_subnet_dhcp_options doesn't create
|
||||
# a new row in DHCP_Options if the row already exists.
|
||||
# See commands.AddDHCPOptionsCommand.
|
||||
|
@ -104,6 +104,17 @@ class TestOvnNbSyncML2(test_mech_driver.OVNMechanismDriverTestCase):
|
||||
'gateway_ip': '20.0.0.1',
|
||||
'dns_nameservers': [],
|
||||
'host_routes': [],
|
||||
'ip_version': 4},
|
||||
# A subnet without a known network should be skipped,
|
||||
# see bug #2045811
|
||||
{'id': 'notfound',
|
||||
'network_id': 'notfound',
|
||||
'enable_dhcp': True,
|
||||
'cidr': '30.0.0.0/24',
|
||||
'tenant_id': 'tenant1',
|
||||
'gateway_ip': '30.0.0.1',
|
||||
'dns_nameservers': [],
|
||||
'host_routes': [],
|
||||
'ip_version': 4}]
|
||||
|
||||
self.security_groups = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user