Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -856,10 +856,20 @@ def _sync_subnet_dhcp_options(self, ctx, db_networks,
LOG.warning('DHCP options for subnet %s is present in '
'Neutron but out of sync for OVN', 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.debug('Adding/Updating DHCP options for subnet %s in '
' OVN NB DB', subnet_id)
network = db_networks[utils.ovn_name(subnet['network_id'])]
LOG.warning('Adding/Updating DHCP options for subnet %s '
'in OVN NB DB', subnet_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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ def setUp(self):
'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 = [
Expand Down