diff --git a/octavia/controller/worker/v2/tasks/network_tasks.py b/octavia/controller/worker/v2/tasks/network_tasks.py index ede13c70d7..489db0eac2 100644 --- a/octavia/controller/worker/v2/tasks/network_tasks.py +++ b/octavia/controller/worker/v2/tasks/network_tasks.py @@ -984,10 +984,9 @@ class CreateVIPBasePort(BaseNetworkTask): return try: port_name = constants.AMP_BASE_PORT_PREFIX + amphora_id - for port in result: - self.network_driver.delete_port(port.id) - LOG.info('Deleted port %s with ID %s for amphora %s due to a ' - 'revert.', port_name, port.id, amphora_id) + self.network_driver.delete_port(result[constants.ID]) + LOG.info('Deleted port %s with ID %s for amphora %s due to a ' + 'revert.', port_name, result[constants.ID], amphora_id) except Exception as e: LOG.error('Failed to delete port %s. Resources may still be in ' 'use for a port intended for amphora %s due to error ' diff --git a/octavia/tests/unit/controller/worker/v2/tasks/test_network_tasks.py b/octavia/tests/unit/controller/worker/v2/tasks/test_network_tasks.py index 723f22ecd3..a96ea862f3 100644 --- a/octavia/tests/unit/controller/worker/v2/tasks/test_network_tasks.py +++ b/octavia/tests/unit/controller/worker/v2/tasks/test_network_tasks.py @@ -1670,7 +1670,11 @@ class TestNetworkTasks(base.TestCase): # Test revert mock_driver.reset_mock() - net_task.revert([port_mock], vip_dict, VIP_SG_ID, AMP_ID, + # The execute path generates a port dict, so this will be the result + # passed into the revert method by Taskflow + port_dict = {constants.ID: PORT_ID} + + net_task.revert(port_dict, vip_dict, VIP_SG_ID, AMP_ID, additional_vips) mock_driver.delete_port.assert_called_once_with(PORT_ID) @@ -1678,7 +1682,7 @@ class TestNetworkTasks(base.TestCase): # Test revert exception mock_driver.reset_mock() - net_task.revert([port_mock], vip_dict, VIP_SG_ID, AMP_ID, + net_task.revert(port_dict, vip_dict, VIP_SG_ID, AMP_ID, additional_vips) mock_driver.delete_port.assert_called_once_with(PORT_ID) diff --git a/releasenotes/notes/Fix-failover-revert-port-leak-d9879523506c6ff3.yaml b/releasenotes/notes/Fix-failover-revert-port-leak-d9879523506c6ff3.yaml new file mode 100644 index 0000000000..79610cebc4 --- /dev/null +++ b/releasenotes/notes/Fix-failover-revert-port-leak-d9879523506c6ff3.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixed an issue when a failover reverts, a neutron port may get abandoned. + The issue was logged with "Failed to delete port", + "Resources may still be in use for a port intended for amphora", and + "Search for a port named octavia-lb-vrrp-".