From 77dc23fc26cbb8c6488b5205c63bf7cc847a9c32 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Wed, 7 Oct 2020 15:59:50 -0700 Subject: [PATCH] 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 --- octavia/controller/worker/v1/tasks/amphora_driver_tasks.py | 3 +++ .../controller/worker/v1/tasks/test_amphora_driver_tasks.py | 5 ++++- .../notes/fix-dual-error-amp-failover-69e323892bad8254.yaml | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-dual-error-amp-failover-69e323892bad8254.yaml diff --git a/octavia/controller/worker/v1/tasks/amphora_driver_tasks.py b/octavia/controller/worker/v1/tasks/amphora_driver_tasks.py index bad1ffa250..fbae914763 100644 --- a/octavia/controller/worker/v1/tasks/amphora_driver_tasks.py +++ b/octavia/controller/worker/v1/tasks/amphora_driver_tasks.py @@ -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: diff --git a/octavia/tests/unit/controller/worker/v1/tasks/test_amphora_driver_tasks.py b/octavia/tests/unit/controller/worker/v1/tasks/test_amphora_driver_tasks.py index c1ded1ae5a..fc4963436c 100644 --- a/octavia/tests/unit/controller/worker/v1/tasks/test_amphora_driver_tasks.py +++ b/octavia/tests/unit/controller/worker/v1/tasks/test_amphora_driver_tasks.py @@ -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') diff --git a/releasenotes/notes/fix-dual-error-amp-failover-69e323892bad8254.yaml b/releasenotes/notes/fix-dual-error-amp-failover-69e323892bad8254.yaml new file mode 100644 index 0000000000..5240b7a186 --- /dev/null +++ b/releasenotes/notes/fix-dual-error-amp-failover-69e323892bad8254.yaml @@ -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.