Skip to content

Commit ec234e6

Browse files
ralonsohmihaela-irina-paval
authored andcommitted
Port provisioning should retry only for VM ports
The port provisioning method ``Ml2Plugin._port_provisioned`` creates an active wait to provision a port if the port is unbound since [1]. But this active wait should consider only VM ports in the case of live migration, as described in the LP bug [2]. This wait should not consider auxiliary Neutron ports or baremetal ports (we don't live-migrate then). [1]https://review.opendev.org/c/openstack/neutron/+/855257 [2]https://bugs.launchpad.net/neutron/+bug/1988199 Closes-Bug: #1991092 Change-Id: Ic8891e2deef4bb5e72cf7d7f37b043e936adbc00 (cherry picked from commit 21491ef)
1 parent 5684138 commit ec234e6

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

neutron/plugins/ml2/plugin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ def _port_provisioned(self, rtype, event, trigger, payload=None):
355355
# a host ID and the dhcp agent notifies that its wiring is done
356356
LOG.debug('Port %s cannot update to ACTIVE because it '
357357
'is not bound.', port_id)
358-
if count == MAX_PROVISIONING_TRIES:
358+
owner = port.device_owner
359+
if (count == MAX_PROVISIONING_TRIES or not
360+
owner.startswith(const.DEVICE_OWNER_COMPUTE_PREFIX)):
359361
return
360362

361363
# Wait 0.5 seconds before checking again if the port is bound.

neutron/tests/unit/plugins/ml2/test_plugin.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,9 @@ def test__port_provisioned_port_retry_port_binding_unbound(
11261126
ml2_plugin.MAX_PROVISIONING_TRIES = 2
11271127
plugin = directory.get_plugin()
11281128
port_id = 'fake_port_id'
1129-
port = mock.Mock(id=port_id, admin_state_up=True)
1129+
device_owner = constants.DEVICE_OWNER_COMPUTE_PREFIX + 'nova'
1130+
port = mock.Mock(id=port_id, admin_state_up=True,
1131+
device_owner=device_owner)
11301132
mock_get_port.return_value = port
11311133
with mock.patch.object(plugin, 'update_port_status') as mock_pstatus:
11321134
pb1 = mock.MagicMock(vif_type=portbindings.VIF_TYPE_UNBOUND)
@@ -1139,6 +1141,23 @@ def test__port_provisioned_port_retry_port_binding_unbound(
11391141
mock_pstatus.assert_called_once_with(self.context, port_id,
11401142
constants.PORT_STATUS_ACTIVE)
11411143

1144+
@mock.patch('neutron.plugins.ml2.plugin.db.get_port')
1145+
@mock.patch.object(p_utils, 'get_port_binding_by_status_and_host')
1146+
def test__port_provisioned_port_retry_port_binding_unbound_no_vm_port(
1147+
self, mock_get_pb, mock_get_port):
1148+
plugin = directory.get_plugin()
1149+
port_id = 'fake_port_id'
1150+
port = mock.Mock(id=port_id, admin_state_up=True,
1151+
device_owner='other_value')
1152+
mock_get_port.return_value = port
1153+
with mock.patch.object(plugin, 'update_port_status') as mock_pstatus:
1154+
pb1 = mock.MagicMock(vif_type=portbindings.VIF_TYPE_UNBOUND)
1155+
mock_get_pb.return_value = pb1
1156+
plugin._port_provisioned('port', 'evt', 'trigger',
1157+
payload=events.DBEventPayload(
1158+
self.context, resource_id=port_id))
1159+
mock_pstatus.assert_not_called()
1160+
11421161
def test_port_after_create_outside_transaction(self):
11431162
self.tx_open = True
11441163

0 commit comments

Comments
 (0)