Skip to content

Commit 9db9903

Browse files
authored
Merge pull request #92 from stackhpc/upstream/yoga-2023-12-11
Synchronise yoga with upstream
2 parents cfef42c + 040a96e commit 9db9903

File tree

9 files changed

+98
-70
lines changed

9 files changed

+98
-70
lines changed

neutron/agent/linux/dhcp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,8 @@ def _get_ovn_metadata_port_ip(self, subnet):
11441144
m_ports = [port for port in self.network.ports if
11451145
self._is_ovn_metadata_port(port, self.network.id)]
11461146
if m_ports:
1147-
for fixed_ip in m_ports[0].fixed_ips:
1147+
port = self.device_manager.plugin.get_dhcp_port(m_ports[0].id)
1148+
for fixed_ip in port.fixed_ips:
11481149
if fixed_ip.subnet_id == subnet.id:
11491150
return fixed_ip.ip_address
11501151

@@ -1220,7 +1221,7 @@ def _generate_opts_per_subnet(self):
12201221
if subnet_dhcp_ip:
12211222
metadata_route_ip = subnet_dhcp_ip
12221223

1223-
if not isolated_subnets[subnet.id] and gateway:
1224+
elif not isolated_subnets[subnet.id] and gateway:
12241225
metadata_route_ip = gateway
12251226

12261227
if metadata_route_ip:

neutron/conf/agent/metadata/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
cfg.IntOpt('metadata_workers',
9595
sample_default='<num_of_cpus> / 2',
9696
help=_('Number of separate worker processes for metadata '
97-
'server (defaults to 2 when used with ML2/OVN and half '
97+
'server (defaults to 0 when used with ML2/OVN and half '
9898
'of the number of CPUs with other backend drivers)')),
9999
cfg.IntOpt('metadata_backlog',
100100
default=4096,

neutron/privileged/agent/linux/ip_lib.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,10 @@ def delete_neigh_entry(ip_version, ip_address, mac_address, device, namespace,
474474
if e.code == errno.ENOENT:
475475
return
476476
raise
477+
except OSError as e:
478+
if e.errno == errno.ENOENT:
479+
raise NetworkNamespaceNotFound(netns_name=namespace)
480+
raise
477481

478482

479483
@tenacity.retry(
@@ -683,6 +687,11 @@ def delete_ip_rule(namespace, **kwargs):
683687
try:
684688
with get_iproute(namespace) as ip:
685689
ip.rule('del', **kwargs)
690+
except netlink_exceptions.NetlinkError as e:
691+
# trying to delete a non-existent entry shouldn't raise an error
692+
if e.code == errno.ENOENT:
693+
return
694+
raise
686695
except OSError as e:
687696
if e.errno == errno.ENOENT:
688697
raise NetworkNamespaceNotFound(netns_name=namespace)
@@ -785,6 +794,11 @@ def delete_ip_route(namespace, cidr, ip_version, device=None, via=None,
785794
try:
786795
with get_iproute(namespace) as ip:
787796
ip.route('del', **kwargs)
797+
except netlink_exceptions.NetlinkError as e:
798+
# trying to delete a non-existent entry shouldn't raise an error
799+
if e.code == errno.ESRCH:
800+
return
801+
raise
788802
except OSError as e:
789803
if e.errno == errno.ENOENT:
790804
raise NetworkNamespaceNotFound(netns_name=namespace)
@@ -819,6 +833,11 @@ def _command_bridge_fdb(command, mac, device, dst_ip=None, namespace=None,
819833
kwargs['dst'] = dst_ip
820834
with get_iproute(namespace) as ip:
821835
return make_serializable(ip.fdb(command, **kwargs))
836+
except netlink_exceptions.NetlinkError as e:
837+
# trying to delete a non-existent entry shouldn't raise an error
838+
if command == 'del' and e.code == errno.ENOENT:
839+
return
840+
raise
822841
except OSError as e:
823842
if e.errno == errno.ENOENT:
824843
raise NetworkNamespaceNotFound(netns_name=namespace)
@@ -834,20 +853,20 @@ def add_bridge_fdb(mac, device, dst_ip=None, namespace=None, **kwargs):
834853

835854
@privileged.default.entrypoint
836855
def append_bridge_fdb(mac, device, dst_ip=None, namespace=None, **kwargs):
837-
"""Add a FDB entry"""
856+
"""Append a FDB entry"""
838857
return _command_bridge_fdb('append', mac, device, dst_ip=dst_ip,
839858
namespace=namespace, **kwargs)
840859

841860

842861
@privileged.default.entrypoint
843862
def replace_bridge_fdb(mac, device, dst_ip=None, namespace=None, **kwargs):
844-
"""Add a FDB entry"""
863+
"""Replace a FDB entry"""
845864
return _command_bridge_fdb('replace', mac, device, dst_ip=dst_ip,
846865
namespace=namespace, **kwargs)
847866

848867

849868
@privileged.default.entrypoint
850869
def delete_bridge_fdb(mac, device, dst_ip=None, namespace=None, **kwargs):
851-
"""Add a FDB entry"""
870+
"""Delete a FDB entry"""
852871
return _command_bridge_fdb('del', mac, device, dst_ip=dst_ip,
853872
namespace=namespace, **kwargs)

neutron/tests/functional/agent/linux/test_bridge_lib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ def test_add_delete(self):
211211
namespace=self.namespace)
212212
self._assert_mac(self.MAC1, self.device, present=False)
213213

214+
try:
215+
# This should not raise for a non-existent entry
216+
bridge_lib.FdbInterface.delete(self.MAC1, self.device,
217+
namespace=self.namespace)
218+
except Exception:
219+
self.fail('Delete FDB entry threw unexpected exception')
220+
214221
def test_add_delete_dst(self):
215222
self._assert_mac(self.MAC1, self.device_vxlan, present=False)
216223
bridge_lib.FdbInterface.add(

neutron/tests/functional/privileged/agent/linux/test_ip_lib.py

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -239,19 +239,34 @@ def test_get_devices_info_veth_same_namespaces(self):
239239
self.assertEqual(veth1_2['index'], veth1_1_link)
240240

241241

242-
class ListIpRulesTestCase(functional_base.BaseSudoTestCase):
243-
244-
RULE_TABLES = {'default': 253, 'main': 254, 'local': 255}
242+
class BaseIpRuleTestCase(functional_base.BaseSudoTestCase):
245243

246244
def setUp(self):
247-
super(ListIpRulesTestCase, self).setUp()
245+
super().setUp()
248246
self.namespace = 'ns_test-' + uuidutils.generate_uuid()
249247
self.ns = priv_ip_lib.create_netns(self.namespace)
250248
self.addCleanup(self._remove_ns)
251249

252250
def _remove_ns(self):
253251
priv_ip_lib.remove_netns(self.namespace)
254252

253+
def _check_rules(self, rules, parameters, values, exception_string=None,
254+
raise_exception=True):
255+
for rule in rules:
256+
if all(rule.get(parameter) == value
257+
for parameter, value in zip(parameters, values)):
258+
return True
259+
else:
260+
if raise_exception:
261+
self.fail('Rule with %s was expected' % exception_string)
262+
else:
263+
return False
264+
265+
266+
class ListIpRulesTestCase(BaseIpRuleTestCase):
267+
268+
RULE_TABLES = {'default': 253, 'main': 254, 'local': 255}
269+
255270
def test_list_default_rules_ipv4(self):
256271
rules_ipv4 = priv_ip_lib.list_ip_rules(self.namespace, 4)
257272
self.assertEqual(3, len(rules_ipv4))
@@ -291,28 +306,7 @@ def test_list_rules_ipv6(self):
291306
self.fail('Rule added (2001:db8::1/64, table 20) not found')
292307

293308

294-
class RuleTestCase(functional_base.BaseSudoTestCase):
295-
296-
def setUp(self):
297-
super(RuleTestCase, self).setUp()
298-
self.namespace = 'ns_test-' + uuidutils.generate_uuid()
299-
self.ns = priv_ip_lib.create_netns(self.namespace)
300-
self.addCleanup(self._remove_ns)
301-
302-
def _remove_ns(self):
303-
priv_ip_lib.remove_netns(self.namespace)
304-
305-
def _check_rules(self, rules, parameters, values, exception_string=None,
306-
raise_exception=True):
307-
for rule in rules:
308-
if all(rule.get(parameter) == value
309-
for parameter, value in zip(parameters, values)):
310-
return True
311-
else:
312-
if raise_exception:
313-
self.fail('Rule with %s was expected' % exception_string)
314-
else:
315-
return False
309+
class AddIpRulesTestCase(BaseIpRuleTestCase):
316310

317311
def test_add_rule_ip(self):
318312
ip_addresses = ['192.168.200.250', '2001::250']
@@ -433,6 +427,23 @@ def test_add_rule_exists(self):
433427
self.assertEqual(4, len(rules))
434428

435429

430+
class DeleteIpRulesTestCase(BaseIpRuleTestCase):
431+
432+
def test_delete_rule_no_entry(self):
433+
iif = 'iif_device'
434+
priv_ip_lib.create_interface(iif, self.namespace, 'dummy')
435+
436+
try:
437+
# This should not raise for a non-existent entry
438+
priv_ip_lib.delete_ip_rule(self.namespace, iifname=iif)
439+
except Exception:
440+
self.fail('Delete IP rule threw unexpected exception')
441+
442+
rules = ip_lib.list_ip_rules(self.namespace, 4)
443+
# There are always 3 rules by default
444+
self.assertEqual(3, len(rules))
445+
446+
436447
class GetIpAddressesTestCase(functional_base.BaseSudoTestCase):
437448

438449
def _remove_ns(self, namespace):
@@ -659,6 +670,21 @@ def test_add_multipath_route(self):
659670
n_cons.IP_VERSION_4, via=multipath)
660671
self._check_routes(['192.168.0.0/24'], gateway=multipath)
661672

673+
def test_delete_route_no_entry(self):
674+
cidr = '192.168.0.0/24'
675+
self.device.addr.add('10.1.0.1/24')
676+
try:
677+
# This should not raise for a non-existent entry
678+
priv_ip_lib.delete_ip_route(self.namespace, cidr,
679+
n_cons.IP_VERSION_4,
680+
device=self.device_name)
681+
except Exception:
682+
self.fail('Delete IP route threw unexpected exception')
683+
684+
routes = ip_lib.list_ip_routes(self.namespace, n_cons.IP_VERSION_4)
685+
# There will be a single interface route since we added an IP
686+
self.assertEqual(1, len(routes))
687+
662688

663689
class GetLinkAttributesTestCase(functional_base.BaseSudoTestCase):
664690

neutron/tests/unit/agent/linux/test_dhcp.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,6 +3126,8 @@ def test__generate_opts_per_subnet_no_metadata(self):
31263126
def test__generate_opts_per_subnet_with_metadata_port(self):
31273127
config = {'enable_isolated_metadata': False,
31283128
'force_metadata': False}
3129+
self.mock_mgr.return_value.plugin.get_dhcp_port.return_value = \
3130+
FakeOvnMetadataPort()
31293131
self._test__generate_opts_per_subnet_helper(config, True,
31303132
network_class=FakeNetworkDhcpandOvnMetadataPort)
31313133

neutron/tests/unit/privileged/agent/linux/test_ip_lib.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ def test_run_iproute_neigh_namespace_not_exists(self):
157157
priv_lib._run_iproute_neigh,
158158
"test_cmd", "eth0", None, test_param="test_value")
159159

160+
def test_run_iproute_neigh_no_entry(self):
161+
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
162+
iproute_mock.side_effect = netlink_exceptions.NetlinkError(
163+
code=errno.ENOENT)
164+
try:
165+
priv_lib._run_iproute_neigh(
166+
"test_cmd", "eth0", None, test_param="test_value")
167+
self.fail("NetlinkError exception not raised")
168+
except netlink_exceptions.NetlinkError as e:
169+
self.assertEqual(errno.ENOENT, e.code)
170+
160171
def test_run_iproute_neigh_error(self):
161172
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
162173
iproute_mock.side_effect = OSError(

zuul.d/job-templates.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@
100100
- neutron-ovn-tempest-mariadb-full
101101
- neutron-ovn-tempest-ovs-release
102102
- neutron-ovn-tempest-ovs-release-ipv6-only
103-
- neutron-ovs-tempest-fips
104-
- neutron-ovn-tempest-ovs-release-fips
105103
- devstack-tobiko-neutron:
106104
voting: true
107105
- ironic-tempest-ipa-wholedisk-bios-agent_ipmitool-tinyipa

zuul.d/tempest-singlenode.yaml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -491,39 +491,3 @@
491491
name: neutron-ovn-tempest-ovs-release
492492
description: Job testing for devstack/tempest testing Neutron with ovn driver and latest released OVN branch
493493
parent: neutron-ovn-base
494-
495-
- job:
496-
name: neutron-ovs-tempest-fips
497-
parent: neutron-ovs-tempest-base
498-
nodeset: devstack-single-node-centos-9-stream
499-
description: |
500-
Scenario testing for a FIPS enabled Centos 9 system
501-
pre-run: playbooks/enable-fips.yaml
502-
vars:
503-
nslookup_target: 'opendev.org'
504-
configure_swap_size: 4096
505-
devstack_services:
506-
br-ex-tcpdump: true
507-
br-int-flows: true
508-
devstack_local_conf:
509-
test-config:
510-
"$TEMPEST_CONFIG":
511-
validation:
512-
ssh_key_type: 'ecdsa'
513-
514-
515-
- job:
516-
name: neutron-ovn-tempest-ovs-release-fips
517-
parent: neutron-ovn-tempest-ovs-release
518-
nodeset: devstack-single-node-centos-9-stream
519-
description: |
520-
Scenario testing for a FIPS enabled Centos 9 system
521-
pre-run: playbooks/enable-fips.yaml
522-
vars:
523-
nslookup_target: 'opendev.org'
524-
configure_swap_size: 4096
525-
devstack_local_conf:
526-
test-config:
527-
"$TEMPEST_CONFIG":
528-
validation:
529-
ssh_key_type: 'ecdsa'

0 commit comments

Comments
 (0)