Skip to content

Commit d294a8f

Browse files
authored
Merge pull request #112 from stackhpc/upstream/2023.1-2024-01-15
Synchronise 2023.1 with upstream
2 parents 1588ebd + 94cf7a4 commit d294a8f

File tree

5 files changed

+61
-24
lines changed

5 files changed

+61
-24
lines changed

neutron/agent/ovn/extensions/qos_hwol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ class PortBindingChassisCreatedEvent(_PortBindingChassisEvent):
158158
LOG_MSG = 'Port ID %s, datapath %s, OVS port name: %s (event: %s)'
159159

160160
def __init__(self, ovn_agent):
161-
events = (self.ROW_UPDATE,)
161+
events = (self.ROW_CREATE, self.ROW_UPDATE,)
162162
super().__init__(ovn_agent, events)
163163

164164
def match_fn(self, event, row, old):
165165
try:
166166
return (row.chassis[0].name == self.ovn_agent.chassis and
167-
not old.chassis)
167+
(event == self.ROW_CREATE or not old.chassis))
168168
except (IndexError, AttributeError):
169169
return False
170170

neutron/agent/ovn/metadata/agent.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ def run(self, event, row, old):
109109
self.agent.resync()
110110

111111

112+
class PortBindingCreateWithChassis(PortBindingEvent):
113+
EVENT = PortBindingEvent.ROW_CREATE
114+
115+
def match_fn(self, event, row, old):
116+
self._log_msg = "Port %s in datapath %s bound to our chassis on insert"
117+
if not (super().match_fn(event, row, old) and row.chassis):
118+
return False
119+
return row.chassis[0].name == self.agent.chassis
120+
121+
112122
class PortBindingUpdatedEvent(PortBindingEvent):
113123
EVENT = PortBindingEvent.ROW_UPDATE
114124

@@ -316,6 +326,7 @@ def start(self):
316326
tables = ('Encap', 'Port_Binding', 'Datapath_Binding', 'SB_Global',
317327
'Chassis')
318328
events = (PortBindingUpdatedEvent(self),
329+
PortBindingCreateWithChassis(self),
319330
PortBindingDeletedEvent(self),
320331
SbGlobalUpdateEvent(self),
321332
)
@@ -345,7 +356,8 @@ def start(self):
345356
self._proxy.run()
346357

347358
# Do the initial sync.
348-
self.sync()
359+
# Provisioning handled by PortBindingCreateWithChassis
360+
self.sync(provision=False)
349361

350362
# Register the agent with its corresponding Chassis
351363
self.register_metadata_agent()
@@ -396,7 +408,7 @@ def get_networks_datapaths(self):
396408
return set(p.datapath for p in self._vif_ports(ports))
397409

398410
@_sync_lock
399-
def sync(self):
411+
def sync(self, provision=True):
400412
"""Agent sync.
401413
402414
This function will make sure that all networks with ports in our
@@ -423,8 +435,9 @@ def sync(self):
423435
# resync all network namespaces based on the associated datapaths,
424436
# even those that are already running. This is to make sure
425437
# everything within each namespace is up to date.
426-
for datapath in net_datapaths:
427-
self.provision_datapath(datapath)
438+
if provision:
439+
for datapath in net_datapaths:
440+
self.provision_datapath(datapath)
428441

429442
@staticmethod
430443
def _get_veth_name(datapath):

neutron/conf/agent/database/agents_db.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
from neutron.common import _constants
1717

1818
AGENT_OPTS = [
19+
# The agent_down_time value can only be a max of INT_MAX (as defined in C),
20+
# where int is usually 32 bits. The agent_down_time will be passed to
21+
# eventlet in milliseconds and any number higher will produce an OverFlow
22+
# error. More details here: https://bugs.launchpad.net/neutron/+bug/2028724
1923
cfg.IntOpt('agent_down_time', default=75,
24+
max=((2**32 / 2 - 1) // 1000),
2025
help=_("Seconds to regard the agent is down; should be at "
2126
"least twice report_interval, to be sure the "
2227
"agent is down for good.")),

neutron/tests/functional/agent/ovn/extensions/test_qos_hwol.py

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,65 @@
1717

1818
from oslo_utils import uuidutils
1919

20-
from neutron.agent.common import ovs_lib
2120
from neutron.agent.ovn.agent import ovsdb as agent_ovsdb
2221
from neutron.agent.ovn.extensions import qos_hwol
2322
from neutron.common.ovn import constants as ovn_const
2423
from neutron.common.ovn import utils
2524
from neutron.common import utils as n_utils
2625
from neutron.tests import base as test_base
27-
from neutron.tests.common import net_helpers
2826
from neutron.tests.functional import base
2927

3028

3129
class OVSInterfaceEventTestCase(base.TestOVNFunctionalBase):
3230

33-
@test_base.unstable_test(
34-
'LP#2006603, it is being addressed in '
35-
'https://review.opendev.org/c/openstack/neutron/+/873118')
31+
def _cleanup(self):
32+
self.ovs_idl.del_port(self.port_name, bridge=self.br_name).execute(
33+
check_error=False)
34+
self.ovs_idl.del_br(self.br_name).execute(check_error=False)
35+
36+
@test_base.unstable_test('bug 2006603')
3637
def test_port_creation_and_deletion(self):
3738
def check_add_port_called():
3839
try:
3940
mock_agent.qos_hwol_ext.add_port.assert_has_calls(
40-
[mock.call('port_iface-id', port_name)])
41+
[mock.call(port_iface_id, self.port_name)])
4142
return True
4243
except AssertionError:
4344
return False
4445

4546
def check_remove_egress_called():
4647
try:
4748
mock_agent.qos_hwol_ext.remove_egress.assert_has_calls(
48-
[mock.call('port_iface-id')])
49+
[mock.call(port_iface_id)])
4950
return True
5051
except AssertionError:
5152
return False
5253

54+
port_iface_id = 'port_iface-id'
5355
mock_agent = mock.Mock()
5456
events = [qos_hwol.OVSInterfaceEvent(mock_agent)]
55-
agent_ovsdb.MonitorAgentOvsIdl(events=events).start()
56-
br = self.useFixture(net_helpers.OVSBridgeFixture()).bridge
57-
self.ovs_bridge = ovs_lib.OVSBridge(br.br_name)
58-
port_name = ('port-' + uuidutils.generate_uuid())[:8]
59-
60-
self.ovs_bridge.add_port(
61-
port_name, ('external_ids', {'iface-id': 'port_iface-id'}))
62-
n_utils.wait_until_true(check_add_port_called, timeout=5)
63-
64-
self.ovs_bridge.delete_port(port_name)
65-
n_utils.wait_until_true(check_remove_egress_called, timeout=5)
57+
self.ovs_idl = agent_ovsdb.MonitorAgentOvsIdl(events=events).start()
58+
self.br_name = ('brtest-' + uuidutils.generate_uuid())[:13]
59+
self.port_name = ('port-' + uuidutils.generate_uuid())[:13]
60+
self.addCleanup(self._cleanup)
61+
with self.ovs_idl.transaction() as txn:
62+
txn.add(self.ovs_idl.add_br(self.br_name))
63+
txn.add(self.ovs_idl.add_port(self.br_name, self.port_name))
64+
txn.add(self.ovs_idl.iface_set_external_id(
65+
self.port_name, 'iface-id', port_iface_id))
66+
txn.add(self.ovs_idl.db_set(
67+
'Interface', self.port_name, ('type', 'internal')))
68+
69+
exc = Exception('Port %s was not added to the bridge %s' %
70+
(self.port_name, self.br_name))
71+
n_utils.wait_until_true(check_add_port_called, timeout=5,
72+
exception=exc)
73+
74+
self.ovs_idl.del_port(self.port_name).execute(check_error=True)
75+
exc = Exception('Port %s was not deleted from the bridge %s' %
76+
(self.port_name, self.br_name))
77+
n_utils.wait_until_true(check_remove_egress_called, timeout=5,
78+
exception=exc)
6679

6780

6881
class QoSBandwidthLimitEventTestCase(base.TestOVNFunctionalBase):
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
The config option ``agent_down_time`` is now limited to a maximum value of
5+
`2147483`, as neutron-server will fail to start if it is configured higher.
6+
See bug `2028724 <https://bugs.launchpad.net/neutron/+bug/2028724>`_ for more information.

0 commit comments

Comments
 (0)