Skip to content

Commit f75ef1c

Browse files
authored
Merge pull request #138 from stackhpc/upstream/zed-2024-04-22
Synchronise zed with upstream
2 parents 0eabff0 + 4fc3c71 commit f75ef1c

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
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
@@ -863,10 +863,20 @@ def _sync_subnet_dhcp_options(self, ctx, db_networks,
863863
LOG.warning('DHCP options for subnet %s is present in '
864864
'Neutron but out of sync for OVN', subnet_id)
865865
if self.mode == SYNC_MODE_REPAIR:
866+
# If neutron-server is running we could race and find a
867+
# subnet without a cached network, just skip it to avoid
868+
# a KeyError below.
869+
network_id = utils.ovn_name(subnet['network_id'])
870+
if network_id not in db_networks:
871+
LOG.warning('Network %s for subnet %s not found in OVN NB '
872+
'DB network cache, possible race condition, '
873+
'please check that neutron-server is stopped! '
874+
'Skipping subnet.', network_id, subnet_id)
875+
continue
866876
try:
867-
LOG.debug('Adding/Updating DHCP options for subnet %s in '
868-
' OVN NB DB', subnet_id)
869-
network = db_networks[utils.ovn_name(subnet['network_id'])]
877+
LOG.warning('Adding/Updating DHCP options for subnet %s '
878+
'in OVN NB DB', subnet_id)
879+
network = db_networks[network_id]
870880
# _ovn_client._add_subnet_dhcp_options doesn't create
871881
# a new row in DHCP_Options if the row already exists.
872882
# 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 = [

neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,9 +1515,10 @@ def test_enable_subnet_dhcp_options_in_ovn_ipv4(self, grm, gps):
15151515
self.mech_driver.nb_ovn.set_lswitch_port.assert_has_calls(
15161516
set_lsp_calls, any_order=True)
15171517

1518+
@mock.patch.object(ovn_utils, 'get_system_dns_resolvers')
15181519
@mock.patch.object(db_base_plugin_v2.NeutronDbPluginV2, 'get_ports')
15191520
@mock.patch.object(n_net, 'get_random_mac')
1520-
def test_enable_subnet_dhcp_options_in_ovn_ipv6(self, grm, gps):
1521+
def test_enable_subnet_dhcp_options_in_ovn_ipv6(self, grm, gps, gsd):
15211522
grm.return_value = '01:02:03:04:05:06'
15221523
gps.return_value = [
15231524
{'id': 'port-id-1', 'device_owner': 'nova:compute'},
@@ -1530,6 +1531,7 @@ def test_enable_subnet_dhcp_options_in_ovn_ipv6(self, grm, gps):
15301531
{'opt_value': '10::34', 'ip_version': 6,
15311532
'opt_name': 'dns-server'}]},
15321533
{'id': 'port-id-10', 'device_owner': 'network:foo'}]
1534+
gsd.return_value = []
15331535
subnet = {'id': 'subnet-id', 'ip_version': 6, 'cidr': '10::0/64',
15341536
'gateway_ip': '10::1', 'enable_dhcp': True,
15351537
'ipv6_address_mode': 'dhcpv6-stateless',
@@ -1696,7 +1698,9 @@ def test_update_subnet_dhcp_options_in_ovn_ipv6(self):
16961698
self.mech_driver.nb_ovn.add_dhcp_options.assert_called_once_with(
16971699
subnet['id'], **new_options)
16981700

1699-
def test_update_subnet_dhcp_options_in_ovn_ipv6_not_change(self):
1701+
@mock.patch.object(ovn_utils, 'get_system_dns_resolvers')
1702+
def test_update_subnet_dhcp_options_in_ovn_ipv6_not_change(self, gsd):
1703+
gsd.return_value = []
17001704
subnet = {'id': 'subnet-id', 'ip_version': 6, 'cidr': '10::0/64',
17011705
'gateway_ip': '10::1', 'enable_dhcp': True,
17021706
'ipv6_address_mode': 'dhcpv6-stateless',

0 commit comments

Comments
 (0)