Skip to content

Commit 601b01f

Browse files
committed
[OVN] Try to bind ports only to the ovn-controller agents
Patch [1] added getting ovn agents from the agents cache and check if agent is alive to bound port to it. Small issue with it was that it could check e.g. ovn metadata agent from the host as it was only filtering agents by the host on which they are. This patch adds filter on the agent_type so only ovn-controller agents are taken from the cache. [1] https://review.opendev.org/c/openstack/neutron/+/825428 Related-Bug: #1958501 Change-Id: If065204d7521c480656a22fb078bbe6273b5fc70 (cherry picked from commit eda45de)
1 parent 7032865 commit 601b01f

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,9 @@ def bind_port(self, context):
984984
LOG.error('Validation of binding profile unexpectedly failed '
985985
'while attempting to bind port %s', port['id'])
986986
raise e
987-
agents = n_agent.AgentCache().get_agents({'host': bind_host})
987+
agents = n_agent.AgentCache().get_agents(
988+
{'host': bind_host,
989+
'agent_type': ovn_const.OVN_CONTROLLER_TYPES})
988990
if not agents:
989991
LOG.warning('Refusing to bind port %(port_id)s due to '
990992
'no OVN chassis for host: %(host)s',

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,8 @@ def _test_bind_port_failed(self, fake_segments):
12331233
fake_port, fake_host, fake_segments)
12341234
self.mech_driver.bind_port(fake_port_context)
12351235
neutron_agent.AgentCache().get_agents.assert_called_once_with(
1236-
{'host': fake_host})
1236+
{'host': fake_host,
1237+
'agent_type': ovn_const.OVN_CONTROLLER_TYPES})
12371238
fake_port_context.set_binding.assert_not_called()
12381239

12391240
def test_bind_port_host_not_found(self):
@@ -1263,7 +1264,8 @@ def _test_bind_port(self, fake_segments):
12631264
fake_port, fake_host, fake_segments)
12641265
self.mech_driver.bind_port(fake_port_context)
12651266
neutron_agent.AgentCache().get_agents.assert_called_once_with(
1266-
{'host': fake_host})
1267+
{'host': fake_host,
1268+
'agent_type': ovn_const.OVN_CONTROLLER_TYPES})
12671269
fake_port_context.set_binding.assert_called_once_with(
12681270
fake_segments[0]['id'],
12691271
portbindings.VIF_TYPE_OVS,
@@ -1280,7 +1282,8 @@ def _test_bind_port_sriov(self, fake_segments):
12801282
fake_port, fake_host, fake_segments)
12811283
self.mech_driver.bind_port(fake_port_context)
12821284
neutron_agent.AgentCache().get_agents.assert_called_once_with(
1283-
{'host': fake_host})
1285+
{'host': fake_host,
1286+
'agent_type': ovn_const.OVN_CONTROLLER_TYPES})
12841287
fake_port_context.set_binding.assert_called_once_with(
12851288
fake_segments[0]['id'],
12861289
portbindings.VIF_TYPE_OVS,
@@ -1310,7 +1313,8 @@ def _test_bind_port_remote_managed(self, fake_segments):
13101313
fake_port, fake_host, fake_segments)
13111314
self.mech_driver.bind_port(fake_port_context)
13121315
neutron_agent.AgentCache().get_agents.assert_called_once_with(
1313-
{'host': fake_smartnic_dpu})
1316+
{'host': fake_smartnic_dpu,
1317+
'agent_type': ovn_const.OVN_CONTROLLER_TYPES})
13141318
fake_port_context.set_binding.assert_called_once_with(
13151319
fake_segments[0]['id'],
13161320
portbindings.VIF_TYPE_OVS,
@@ -1331,7 +1335,8 @@ def test_bind_port_vdpa(self):
13311335
fake_port, fake_host, fake_segments)
13321336
self.mech_driver.bind_port(fake_port_context)
13331337
neutron_agent.AgentCache().get_agents.assert_called_once_with(
1334-
{'host': fake_host})
1338+
{'host': fake_host,
1339+
'agent_type': ovn_const.OVN_CONTROLLER_TYPES})
13351340
fake_port_context.set_binding.assert_called_once_with(
13361341
fake_segments[0]['id'],
13371342
portbindings.VIF_TYPE_OVS,

0 commit comments

Comments
 (0)