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
This commit is contained in:
Michael Johnson 2024-02-28 00:37:33 +00:00
parent 3f4eddc5cc
commit 0bfccba150
3 changed files with 16 additions and 6 deletions

View File

@ -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)
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, port.id, amphora_id)
'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 '

View File

@ -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)

View File

@ -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-<uuid>".