Skip to content

Commit 7450a50

Browse files
authored
Merge pull request #137 from stackhpc/upstream/2023.1-2024-04-15
Synchronise 2023.1 with upstream
2 parents 9d7b36d + 2ec0ef0 commit 7450a50

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_db_sync.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,10 +865,20 @@ def _sync_subnet_dhcp_options(self, ctx, db_networks,
865865
LOG.warning('DHCP options for subnet %s is present in '
866866
'Neutron but out of sync for OVN', subnet_id)
867867
if self.mode == SYNC_MODE_REPAIR:
868+
# If neutron-server is running we could race and find a
869+
# subnet without a cached network, just skip it to avoid
870+
# a KeyError below.
871+
network_id = utils.ovn_name(subnet['network_id'])
872+
if network_id not in db_networks:
873+
LOG.warning('Network %s for subnet %s not found in OVN NB '
874+
'DB network cache, possible race condition, '
875+
'please check that neutron-server is stopped! '
876+
'Skipping subnet.', network_id, subnet_id)
877+
continue
868878
try:
869-
LOG.debug('Adding/Updating DHCP options for subnet %s in '
870-
' OVN NB DB', subnet_id)
871-
network = db_networks[utils.ovn_name(subnet['network_id'])]
879+
LOG.warning('Adding/Updating DHCP options for subnet %s '
880+
'in OVN NB DB', subnet_id)
881+
network = db_networks[network_id]
872882
# _ovn_client._add_subnet_dhcp_options doesn't create
873883
# a new row in DHCP_Options if the row already exists.
874884
# See commands.AddDHCPOptionsCommand.

neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovn_db_sync.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ def setUp(self):
104104
'gateway_ip': '20.0.0.1',
105105
'dns_nameservers': [],
106106
'host_routes': [],
107+
'ip_version': 4},
108+
# A subnet without a known network should be skipped,
109+
# see bug #2045811
110+
{'id': 'notfound',
111+
'network_id': 'notfound',
112+
'enable_dhcp': True,
113+
'cidr': '30.0.0.0/24',
114+
'tenant_id': 'tenant1',
115+
'gateway_ip': '30.0.0.1',
116+
'dns_nameservers': [],
117+
'host_routes': [],
107118
'ip_version': 4}]
108119

109120
self.security_groups = [

0 commit comments

Comments
 (0)