Skip to content

Commit de424f5

Browse files
committed
Revert "[OVN][Trunk] Set the subports correct host during live migration"
This reverts commit 82f06fe. Reason for revert: the port binding handling done in this patch is incorrect and leads to issues during the cold migration process with trunk ports in ML2/OVN. Change-Id: If248bcb8b1088edf5ddde20f84cd36cc27c98107 Partial-Bug: #2033887
1 parent 272b3ae commit de424f5

File tree

2 files changed

+9
-41
lines changed

2 files changed

+9
-41
lines changed

neutron/services/trunk/drivers/ovn/trunk_driver.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from neutron_lib.callbacks import events
1515
from neutron_lib.callbacks import registry
1616
from neutron_lib.callbacks import resources
17-
from neutron_lib import constants as n_const
1817
from neutron_lib import context as n_context
1918
from neutron_lib.db import api as db_api
2019
from neutron_lib import exceptions as n_exc
@@ -52,11 +51,7 @@ def _set_sub_ports(self, parent_port, subports):
5251
context = n_context.get_admin_context()
5352
db_parent_port = port_obj.Port.get_object(context, id=parent_port)
5453
parent_port_status = db_parent_port.status
55-
try:
56-
parent_port_bindings = [pb for pb in db_parent_port.bindings
57-
if pb.status == n_const.ACTIVE][-1]
58-
except IndexError:
59-
parent_port_bindings = None
54+
parent_port_bindings = db_parent_port.bindings[0]
6055
for subport in subports:
6156
with db_api.CONTEXT_WRITER.using(context), (
6257
txn(check_error=True)) as ovn_txn:
@@ -90,10 +85,8 @@ def _set_binding_profile(self, context, subport, parent_port,
9085
db_port.id, db_port, ovn_const.TYPE_PORTS)
9186
ovn_txn.add(check_rev_cmd)
9287
parent_binding_host = ''
93-
if parent_port_bindings and parent_port_bindings.host:
94-
migrating_to = parent_port_bindings.profile.get(
95-
ovn_const.MIGRATING_ATTR)
96-
parent_binding_host = migrating_to or parent_port_bindings.host
88+
if parent_port_bindings.host:
89+
parent_binding_host = parent_port_bindings.host
9790
try:
9891
# NOTE(flaviof): We expect binding's host to be set. Otherwise,
9992
# sub-port will not transition from DOWN to ACTIVE.

neutron/tests/functional/services/trunk/drivers/ovn/test_trunk_driver.py

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,13 @@ def _verify_trunk_info(self, trunk, has_items, host=''):
9797
if trunk.get('status'):
9898
self.assertEqual(trunk_consts.TRUNK_ACTIVE_STATUS, trunk['status'])
9999

100-
def _bind_port(self, port_id, host_source, host_dest=None):
100+
def _bind_port(self, port_id, host):
101101
with db_api.CONTEXT_WRITER.using(self.context):
102-
for pb in port_obj.PortBinding.get_objects(self.context,
103-
port_id=port_id):
104-
pb.delete()
105-
profile = {}
106-
if host_dest:
107-
# When "host_dest" there are 2 port bindings, as in a live
108-
# migration; the second one (destination host) is inactive.
109-
profile[ovn_const.MIGRATING_ATTR] = host_dest
110-
port_obj.PortBinding(
111-
self.context, port_id=port_id, host=host_dest,
112-
vif_type=portbindings.VIF_TYPE_OVS,
113-
status=n_consts.INACTIVE).create()
114-
port_obj.PortBinding(
115-
self.context, port_id=port_id, host=host_source,
116-
profile=profile, vif_type=portbindings.VIF_TYPE_OVS).create()
102+
pb = port_obj.PortBinding.get_object(self.context,
103+
port_id=port_id, host='')
104+
pb.delete()
105+
port_obj.PortBinding(self.context, port_id=port_id, host=host,
106+
vif_type=portbindings.VIF_TYPE_OVS).create()
117107

118108
def test_trunk_create(self):
119109
with self.trunk() as trunk:
@@ -158,21 +148,6 @@ def test_subport_add(self):
158148
self._verify_trunk_info(new_trunk, has_items=True,
159149
host='host1')
160150

161-
def test_subport_add_live_migration_multiple_port_binding(self):
162-
with self.subport() as subport:
163-
with self.trunk() as trunk:
164-
self.trunk_plugin.add_subports(self.context, trunk['id'],
165-
{'sub_ports': [subport]})
166-
new_trunk = self.trunk_plugin.get_trunk(self.context,
167-
trunk['id'])
168-
self._verify_trunk_info(new_trunk, has_items=True)
169-
# Bind parent port. That will trigger the binding of the
170-
# trunk subports too, using the same host ID.
171-
self._bind_port(trunk['port_id'], 'host1', host_dest='host2')
172-
self.mech_driver.set_port_status_up(trunk['port_id'])
173-
self._verify_trunk_info(new_trunk, has_items=True,
174-
host='host2')
175-
176151
def test_subport_delete(self):
177152
with self.subport() as subport:
178153
with self.trunk([subport]) as trunk:

0 commit comments

Comments
 (0)