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.