Fix load balancers with failed amphora failover

There was a bug in the load balancer failover code for the amphora
v1 driver where if there were multiple failed amphora, with session
persistence, could cause a load balancer failover to not complete.

Change-Id: Ia46a05ab9fdc97ed9be699e5b2ae90daca3ab9a2
Story: 2008099
Task: 40802
This commit is contained in:
Michael Johnson 2020-10-07 15:59:50 -07:00
parent 418ea0908c
commit 77dc23fc26
3 changed files with 12 additions and 1 deletions

View File

@ -56,6 +56,9 @@ class AmpListenersUpdate(BaseAmphoraTask):
# in a failover flow with both amps failing. Skip it and let
# health manager fix it.
try:
# Make sure we have a fresh load balancer object
loadbalancer = self.loadbalancer_repo.get(db_apis.get_session(),
id=loadbalancer.id)
self.amphora_driver.update_amphora_listeners(
loadbalancer, amphora, timeout_dict)
except Exception as e:

View File

@ -83,7 +83,9 @@ class TestAmphoraDriverTasks(base.TestCase):
constants.CONN_RETRY_INTERVAL: 4}
super().setUp()
@mock.patch('octavia.db.repositories.LoadBalancerRepository.get')
def test_amp_listeners_update(self,
mock_lb_repo_get,
mock_driver,
mock_generate_uuid,
mock_log,
@ -92,12 +94,13 @@ class TestAmphoraDriverTasks(base.TestCase):
mock_listener_repo_update,
mock_amphora_repo_update):
mock_lb_repo_get.return_value = _LB_mock
amp_list_update_obj = amphora_driver_tasks.AmpListenersUpdate()
amp_list_update_obj.execute(_load_balancer_mock, _amphora_mock,
self.timeout_dict)
mock_driver.update_amphora_listeners.assert_called_once_with(
_load_balancer_mock, _amphora_mock, self.timeout_dict)
_LB_mock, _amphora_mock, self.timeout_dict)
mock_driver.update_amphora_listeners.side_effect = Exception('boom')

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixed an issue that could cause load balancers, with multiple amphora
in a failed state, to be unable to complete a failover.