Skip to content

Commit 45e83f5

Browse files
authored
Merge pull request #85 from stackhpc/upstream/zed-2023-11-15
Synchronise zed with upstream
2 parents c961c6f + 3ab7d6e commit 45e83f5

12 files changed

+131
-136
lines changed

neutron/agent/linux/dhcp.py

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,14 @@ def _output_opts_file(self):
11401140
file_utils.replace_file(name, '\n'.join(options))
11411141
return name
11421142

1143+
def _get_ovn_metadata_port_ip(self, subnet):
1144+
m_ports = [port for port in self.network.ports if
1145+
self._is_ovn_metadata_port(port, self.network.id)]
1146+
if m_ports:
1147+
for fixed_ip in m_ports[0].fixed_ips:
1148+
if fixed_ip.subnet_id == subnet.id:
1149+
return fixed_ip.ip_address
1150+
11431151
def _generate_opts_per_subnet(self):
11441152
options = []
11451153
subnets_without_nameservers = set()
@@ -1193,23 +1201,33 @@ def _generate_opts_per_subnet(self):
11931201
else:
11941202
host_routes.append("%s,%s" % (hr.destination, hr.nexthop))
11951203

1196-
# Add host routes for isolated network segments
1197-
1198-
if ((self.conf.force_metadata or
1199-
(isolated_subnets[subnet.id] and
1200-
self.conf.enable_isolated_metadata)) and
1201-
subnet.ip_version == 4):
1202-
subnet_dhcp_ip = subnet_to_interface_ip.get(subnet.id)
1203-
if subnet_dhcp_ip:
1204+
# Determine metadata port route
1205+
if subnet.ip_version == constants.IP_VERSION_4:
1206+
metadata_route_ip = None
1207+
# NOTE: OVN metadata port IP is used in a case when the DHCP
1208+
# agent is deployed in the ML2/OVN enviroment where the native
1209+
# ovn-controller dhcp is disabled. The ovn metadata route
1210+
# takes precedence over native force_metadata and
1211+
# enable_isolated_metadata routes settings.
1212+
ovn_metadata_port_ip = self._get_ovn_metadata_port_ip(subnet)
1213+
if ovn_metadata_port_ip:
1214+
metadata_route_ip = ovn_metadata_port_ip
1215+
1216+
elif (self.conf.force_metadata or
1217+
(isolated_subnets[subnet.id] and
1218+
self.conf.enable_isolated_metadata)):
1219+
subnet_dhcp_ip = subnet_to_interface_ip.get(subnet.id)
1220+
if subnet_dhcp_ip:
1221+
metadata_route_ip = subnet_dhcp_ip
1222+
1223+
if not isolated_subnets[subnet.id] and gateway:
1224+
metadata_route_ip = gateway
1225+
1226+
if metadata_route_ip:
12041227
host_routes.append(
1205-
'%s,%s' % (constants.METADATA_CIDR, subnet_dhcp_ip)
1228+
'%s,%s' % (constants.METADATA_CIDR, metadata_route_ip)
12061229
)
1207-
elif not isolated_subnets[subnet.id] and gateway:
1208-
host_routes.append(
1209-
'%s,%s' % (constants.METADATA_CIDR, gateway)
1210-
)
12111230

1212-
if subnet.ip_version == 4:
12131231
for s in self._get_all_subnets(self.network):
12141232
sub_segment_id = getattr(s, 'segment_id', None)
12151233
if (s.ip_version == 4 and
@@ -1374,13 +1392,21 @@ def has_metadata_subnet(subnets):
13741392
return True
13751393
return False
13761394

1395+
@staticmethod
1396+
def _is_ovn_metadata_port(port, network_id):
1397+
return (port.device_id == 'ovnmeta-' + network_id and
1398+
port.device_owner == constants.DEVICE_OWNER_DISTRIBUTED)
1399+
13771400
@classmethod
13781401
def should_enable_metadata(cls, conf, network):
13791402
"""Determine whether the metadata proxy is needed for a network
13801403
1381-
This method returns True for truly isolated networks (ie: not attached
1382-
to a router) when enable_isolated_metadata is True, or for all the
1383-
networks when the force_metadata flags is True.
1404+
If the given network contains a ovn metadata port then this method
1405+
assumes that the ovn metadata service is in use and this metadata
1406+
service is not required, method returns False. For other cases this
1407+
method returns True for truly isolated networks (ie: not attached to a
1408+
router) when enable_isolated_metadata is True, or for all the networks
1409+
when the force_metadata flags is True.
13841410
13851411
This method also returns True when enable_metadata_network is True,
13861412
and the network passed as a parameter has a subnet in the link-local
@@ -1389,6 +1415,10 @@ def should_enable_metadata(cls, conf, network):
13891415
providing access to the metadata service via logical routers built
13901416
with 3rd party backends.
13911417
"""
1418+
for port in network.ports:
1419+
if cls._is_ovn_metadata_port(port, network.id):
1420+
return False
1421+
13921422
all_subnets = cls._get_all_subnets(network)
13931423
dhcp_subnets = [s for s in all_subnets if s.enable_dhcp]
13941424
if not dhcp_subnets:

neutron/tests/fullstack/test_agent_bandwidth_report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class TestPlacementBandwidthReport(base.BaseFullStackTestCase):
188188
scenarios = [
189189
(constants.AGENT_TYPE_OVS,
190190
{'l2_agent_type': constants.AGENT_TYPE_OVS,
191-
'mech_drivers': 'openvswitch,linuxbridge',
191+
'mech_drivers': 'openvswitch',
192192
'placement_port': '8080'}),
193193
(constants.AGENT_TYPE_NIC_SWITCH,
194194
{'l2_agent_type': constants.AGENT_TYPE_NIC_SWITCH,

neutron/tests/fullstack/test_connectivity.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import testscenarios
2121

2222
from neutron.common import utils as common_utils
23-
from neutron.tests import base as tests_base
2423
from neutron.tests.common import net_helpers
2524
from neutron.tests.fullstack import base
2625
from neutron.tests.fullstack.resources import config
@@ -150,22 +149,6 @@ def test_controller_timeout_does_not_break_connectivity_sigkill(self):
150149
signal.SIGKILL)
151150

152151

153-
class TestLinuxBridgeConnectivitySameNetwork(BaseConnectivitySameNetworkTest):
154-
155-
l2_agent_type = constants.AGENT_TYPE_LINUXBRIDGE
156-
scenarios = [
157-
('VXLAN', {'network_type': 'vxlan',
158-
'l2_pop': False}),
159-
('VLANs', {'network_type': 'vlan',
160-
'l2_pop': False}),
161-
('VXLAN and l2pop', {'network_type': 'vxlan',
162-
'l2_pop': True})
163-
]
164-
165-
def test_connectivity(self):
166-
self._test_connectivity()
167-
168-
169152
class _TestUninterruptedConnectivityOnL2AgentRestart(
170153
BaseConnectivitySameNetworkTest):
171154

@@ -210,20 +193,3 @@ class TestUninterruptedConnectivityOnL2AgentRestartOvs(
210193

211194
def test_l2_agent_restart(self, agent_restart_timeout=20):
212195
self._test_l2_agent_restart(agent_restart_timeout)
213-
214-
215-
class TestUninterruptedConnectivityOnL2AgentRestartLB(
216-
_TestUninterruptedConnectivityOnL2AgentRestart):
217-
218-
scenario = [('LB',
219-
{'l2_agent_type': constants.AGENT_TYPE_LINUXBRIDGE})]
220-
221-
scenarios = (
222-
testscenarios.multiply_scenarios(
223-
scenario,
224-
_TestUninterruptedConnectivityOnL2AgentRestart.network_scenarios)
225-
)
226-
227-
@tests_base.unstable_test("bug 1928764")
228-
def test_l2_agent_restart(self, agent_restart_timeout=20):
229-
self._test_l2_agent_restart(agent_restart_timeout)

neutron/tests/fullstack/test_dhcp_agent.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ class BaseDhcpAgentTest(base.BaseFullStackTestCase):
3333
scenarios = [
3434
(constants.AGENT_TYPE_OVS,
3535
{'l2_agent_type': constants.AGENT_TYPE_OVS}),
36-
(constants.AGENT_TYPE_LINUXBRIDGE,
37-
{'l2_agent_type': constants.AGENT_TYPE_LINUXBRIDGE})
3836
]
3937
boot_vm_for_test = True
4038
dhcp_scheduler_class = None

neutron/tests/fullstack/test_port_shut_down.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ class PortShutDownTest(base.BaseFullStackTestCase):
3737
num_hosts = 1
3838

3939
scenarios = [
40-
(constants.AGENT_TYPE_LINUXBRIDGE,
41-
{'l2_agent_type': constants.AGENT_TYPE_LINUXBRIDGE}),
4240
(constants.AGENT_TYPE_OVS,
4341
{'l2_agent_type': constants.AGENT_TYPE_OVS})
4442
]

neutron/tests/fullstack/test_ports_rebind.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ class TestPortsRebind(base.BaseFullStackTestCase):
3232
('Open vSwitch Agent', {
3333
'l2_agent_type': constants.AGENT_TYPE_OVS,
3434
'l2_mechdriver_name': 'openvswitch',
35-
}),
36-
('Linux Bridge Agent', {
37-
'l2_agent_type': constants.AGENT_TYPE_LINUXBRIDGE,
38-
'l2_mechdriver_name': 'linuxbridge',
3935
})]
4036

4137
def setUp(self):
@@ -170,9 +166,6 @@ def test_vm_port_rebound_when_L2_agent_revived(self):
170166
5. Router's port created in p.3 should be now bound properly
171167
"""
172168

173-
if self.l2_agent_type == constants.AGENT_TYPE_LINUXBRIDGE:
174-
self.skipTest("Bug 1798085")
175-
176169
gw_port = self.safe_client.client.list_ports(
177170
device_id=self.router['id'],
178171
device_owner=constants.DEVICE_OWNER_ROUTER_GW)['ports'][0]

neutron/tests/fullstack/test_qos.py

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from neutronclient.common import exceptions
2121
from oslo_utils import uuidutils
2222

23-
from neutron.agent.linux import tc_lib
2423
from neutron.common import utils
2524
from neutron.tests.common.agents import l2_extensions
2625
from neutron.tests.fullstack import base
@@ -30,11 +29,6 @@
3029
from neutron.tests.unit import testlib_api
3130

3231
from neutron.agent.common import ovs_lib
33-
from neutron.conf.plugins.ml2.drivers import linuxbridge as \
34-
linuxbridge_agent_config
35-
from neutron.plugins.ml2.drivers.linuxbridge.agent import \
36-
linuxbridge_neutron_agent as linuxbridge_agent
37-
from neutron.services.qos.drivers.linuxbridge import driver as lb_drv
3832
from neutron.services.qos.drivers.openvswitch import driver as ovs_drv
3933

4034

@@ -404,46 +398,6 @@ def test_bw_limit_qos_port_removed(self):
404398
self.assertIsNone(qos_queues)
405399

406400

407-
class TestBwLimitQoSLinuxbridge(_TestBwLimitQoS, base.BaseFullStackTestCase):
408-
l2_agent_type = constants.AGENT_TYPE_LINUXBRIDGE
409-
scenarios = [
410-
('egress', {'direction': constants.EGRESS_DIRECTION}),
411-
('ingress', {'direction': constants.INGRESS_DIRECTION}),
412-
]
413-
414-
@staticmethod
415-
def _get_expected_burst_value(limit, direction):
416-
# For egress bandwidth limit this value should be calculated as
417-
# bandwidth_limit * qos_consts.DEFAULT_BURST_RATE
418-
if direction == constants.EGRESS_DIRECTION:
419-
return TestBwLimitQoSLinuxbridge._get_expected_egress_burst_value(
420-
limit)
421-
else:
422-
return TestBwLimitQoSLinuxbridge._get_expected_ingress_burst_value(
423-
limit)
424-
425-
@staticmethod
426-
def _get_expected_ingress_burst_value(limit):
427-
return int(
428-
float(limit) /
429-
float(linuxbridge_agent_config.DEFAULT_KERNEL_HZ_VALUE))
430-
431-
def _wait_for_bw_rule_applied(self, vm, limit, burst, direction):
432-
port_name = linuxbridge_agent.LinuxBridgeManager.get_tap_device_name(
433-
vm.neutron_port['id'])
434-
tc = tc_lib.TcCommand(
435-
port_name,
436-
linuxbridge_agent_config.DEFAULT_KERNEL_HZ_VALUE,
437-
namespace=vm.host.host_namespace
438-
)
439-
if direction == constants.EGRESS_DIRECTION:
440-
utils.wait_until_true(
441-
lambda: tc.get_filters_bw_limits() == (limit, burst))
442-
elif direction == constants.INGRESS_DIRECTION:
443-
utils.wait_until_true(
444-
lambda: tc.get_tbf_bw_limits() == (limit, burst))
445-
446-
447401
class _TestDscpMarkingQoS(BaseQoSRuleTestCase):
448402

449403
number_of_hosts = 2
@@ -540,15 +494,6 @@ def _wait_for_dscp_marking_rule_applied(self, vm, dscp_mark):
540494
vm.bridge, vm.port.name, dscp_mark)
541495

542496

543-
class TestDscpMarkingQoSLinuxbridge(_TestDscpMarkingQoS,
544-
base.BaseFullStackTestCase):
545-
l2_agent_type = constants.AGENT_TYPE_LINUXBRIDGE
546-
547-
def _wait_for_dscp_marking_rule_applied(self, vm, dscp_mark):
548-
l2_extensions.wait_until_dscp_marking_rule_applied_linuxbridge(
549-
vm.host.host_namespace, vm.port.name, dscp_mark)
550-
551-
552497
class _TestPacketRateLimitQoS(BaseQoSRuleTestCase):
553498

554499
number_of_hosts = 1
@@ -644,9 +589,6 @@ class TestQoSWithL2Population(base.BaseFullStackTestCase):
644589
(constants.AGENT_TYPE_OVS,
645590
{'mech_drivers': 'openvswitch',
646591
'supported_rules': ovs_drv.SUPPORTED_RULES}),
647-
(constants.AGENT_TYPE_LINUXBRIDGE,
648-
{'mech_drivers': 'linuxbridge',
649-
'supported_rules': lb_drv.SUPPORTED_RULES})
650592
]
651593

652594
def setUp(self):

neutron/tests/fullstack/test_securitygroup.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ class TestSecurityGroupsSameNetwork(BaseSecurityGroupsSameNetworkTest):
9191

9292
network_type = 'vxlan'
9393
scenarios = [
94-
# TODO(njohnston): Re-add the linuxbridge scenario once it is stable
95-
# The iptables_hybrid driver lacks isolation between agents and
96-
# because of that using only one host is enough
9794
('ovs-hybrid', {
9895
'firewall_driver': 'iptables_hybrid',
9996
'l2_agent_type': constants.AGENT_TYPE_OVS,

neutron/tests/fullstack/test_segmentation_id.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# under the License.
1212

1313
from neutron_lib import constants
14-
from neutronclient.common import exceptions
1514
from oslo_utils import uuidutils
1615

1716
from neutron.tests.common.agents import l2_extensions
@@ -72,8 +71,7 @@ class TestSegmentationId(BaseSegmentationIdTest):
7271

7372
scenarios = [
7473
('Open vSwitch Agent', {'l2_agent_type': constants.AGENT_TYPE_OVS}),
75-
('Linux Bridge Agent', {
76-
'l2_agent_type': constants.AGENT_TYPE_LINUXBRIDGE})]
74+
]
7775
num_hosts = 1
7876

7977
def test_change_segmentation_id_no_ports_in_network(self):
@@ -103,13 +101,7 @@ def test_change_segmentation_id_with_bound_ports_in_network(self):
103101
self.safe_client.create_port(self.project_id, network['id'],
104102
self.environment.hosts[0].hostname)
105103

106-
if self.l2_agent_type == constants.AGENT_TYPE_LINUXBRIDGE:
107-
# Linuxbridge agent don't support update of segmentation_id for
108-
# the network so this should raise an exception
109-
self.assertRaises(exceptions.BadRequest,
110-
self._update_segmentation_id, network)
111-
else:
112-
self._update_segmentation_id(network)
104+
self._update_segmentation_id(network)
113105

114106

115107
class TestSegmentationIdConnectivity(BaseSegmentationIdTest):

0 commit comments

Comments
 (0)