From 0bfccba150da12555e847bcb0707573d99d00da8 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Wed, 28 Feb 2024 00:37:33 +0000 Subject: [PATCH] Fix port abandonment on failover flow revert There was an issue in the failover flow, where if the failover flow reverted after the VIP base (vrrp) port had been created, the revert would fail to delete port as part of the revert. It did however log that it was not cleaning up the port. This patch corrects the issue such that VIP base ports get cleaned up on a failover revert. Change-Id: Iaf08c2bd229165638b4f7f850b26aaf899d540e1 --- octavia/controller/worker/v2/tasks/network_tasks.py | 7 +++---- .../unit/controller/worker/v2/tasks/test_network_tasks.py | 8 ++++++-- .../Fix-failover-revert-port-leak-d9879523506c6ff3.yaml | 7 +++++++ 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/Fix-failover-revert-port-leak-d9879523506c6ff3.yaml 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-".