diff --git a/octavia/controller/worker/v2/controller_worker.py b/octavia/controller/worker/v2/controller_worker.py index fa6ab9d566..8b2491d1e2 100644 --- a/octavia/controller/worker/v2/controller_worker.py +++ b/octavia/controller/worker/v2/controller_worker.py @@ -434,6 +434,14 @@ class ControllerWorker(object): flow_utils.get_update_load_balancer_flow, store=store) + @tenacity.retry( + retry=tenacity.retry_if_exception_type(db_exceptions.NoResultFound), + wait=tenacity.wait_incrementing( + CONF.haproxy_amphora.api_db_commit_retry_initial_delay, + CONF.haproxy_amphora.api_db_commit_retry_backoff, + CONF.haproxy_amphora.api_db_commit_retry_max), + stop=tenacity.stop_after_attempt( + CONF.haproxy_amphora.api_db_commit_retry_attempts)) def create_member(self, member): """Creates a pool member. @@ -693,6 +701,14 @@ class ControllerWorker(object): flow_utils.get_update_pool_flow, store=store) + @tenacity.retry( + retry=tenacity.retry_if_exception_type(db_exceptions.NoResultFound), + wait=tenacity.wait_incrementing( + CONF.haproxy_amphora.api_db_commit_retry_initial_delay, + CONF.haproxy_amphora.api_db_commit_retry_backoff, + CONF.haproxy_amphora.api_db_commit_retry_max), + stop=tenacity.stop_after_attempt( + CONF.haproxy_amphora.api_db_commit_retry_attempts)) def create_l7policy(self, l7policy): """Creates an L7 Policy. @@ -759,6 +775,14 @@ class ControllerWorker(object): flow_utils.get_update_l7policy_flow, store=store) + @tenacity.retry( + retry=tenacity.retry_if_exception_type(db_exceptions.NoResultFound), + wait=tenacity.wait_incrementing( + CONF.haproxy_amphora.api_db_commit_retry_initial_delay, + CONF.haproxy_amphora.api_db_commit_retry_backoff, + CONF.haproxy_amphora.api_db_commit_retry_max), + stop=tenacity.stop_after_attempt( + CONF.haproxy_amphora.api_db_commit_retry_attempts)) def create_l7rule(self, l7rule): """Creates an L7 Rule. @@ -920,7 +944,8 @@ class ControllerWorker(object): constants.LOADBALANCER: provider_lb_dict, constants.SERVER_GROUP_ID: server_group_id, constants.LOADBALANCER_ID: lb_id, - constants.VIP: vip_dict} + constants.VIP: vip_dict, + constants.AMPHORA_ID: amphora_id} self.run_flow( flow_utils.get_failover_amphora_flow, diff --git a/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py b/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py index cdebfbc7ec..1aa2d70a9c 100644 --- a/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py +++ b/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py @@ -191,7 +191,7 @@ class AmphoraIndexListenersReload(BaseAmphoraTask): try: self.amphora_driver.reload(db_lb, db_amp, timeout_dict) except Exception as e: - amphora_id = amphorae[amphora_index].id + amphora_id = amphorae[amphora_index][constants.ID] LOG.warning('Failed to reload listeners on amphora %s. ' 'Skipping this amphora as it is failing to ' 'reload due to: %s', amphora_id, str(e)) diff --git a/octavia/tests/unit/controller/worker/v2/tasks/test_amphora_driver_tasks.py b/octavia/tests/unit/controller/worker/v2/tasks/test_amphora_driver_tasks.py index e1b6c1ac16..e0fc56ebe8 100644 --- a/octavia/tests/unit/controller/worker/v2/tasks/test_amphora_driver_tasks.py +++ b/octavia/tests/unit/controller/worker/v2/tasks/test_amphora_driver_tasks.py @@ -221,7 +221,8 @@ class TestAmphoraDriverTasks(base.TestCase): mock_driver.reload.assert_called_once_with(mock_lb, amphora_mock, self.timeout_dict) mock_amphora_repo_update.assert_called_once_with( - _session_mock, amphora_mock.id, status=constants.ERROR) + _session_mock, amphora_mock[constants.ID], + status=constants.ERROR) @mock.patch('octavia.controller.worker.task_utils.TaskUtils.' 'mark_listener_prov_status_error') diff --git a/octavia/tests/unit/controller/worker/v2/test_controller_worker.py b/octavia/tests/unit/controller/worker/v2/test_controller_worker.py index c5042cfc13..b5fa2e216b 100644 --- a/octavia/tests/unit/controller/worker/v2/test_controller_worker.py +++ b/octavia/tests/unit/controller/worker/v2/test_controller_worker.py @@ -1270,7 +1270,8 @@ class TestControllerWorker(base.TestCase): constants.LOADBALANCER: mock_provider_lb.to_dict(), constants.LOADBALANCER_ID: LB_ID, constants.SERVER_GROUP_ID: None, - constants.VIP: mock_lb.vip.to_dict()} + constants.VIP: mock_lb.vip.to_dict(), + constants.AMPHORA_ID: AMP_ID} cw = controller_worker.ControllerWorker() cw.services_controller.reset_mock() @@ -1325,7 +1326,8 @@ class TestControllerWorker(base.TestCase): constants.LOADBALANCER: mock_provider_lb.to_dict(), constants.LOADBALANCER_ID: LB_ID, constants.SERVER_GROUP_ID: None, - constants.VIP: mock_lb.vip.to_dict()} + constants.VIP: mock_lb.vip.to_dict(), + constants.AMPHORA_ID: AMP_ID} cw = controller_worker.ControllerWorker() cw.services_controller.reset_mock() @@ -1380,7 +1382,8 @@ class TestControllerWorker(base.TestCase): constants.LOADBALANCER: mock_provider_lb.to_dict(), constants.LOADBALANCER_ID: LB_ID, constants.SERVER_GROUP_ID: SERVER_GROUP_ID, - constants.VIP: mock_lb.vip.to_dict()} + constants.VIP: mock_lb.vip.to_dict(), + constants.AMPHORA_ID: AMP_ID} cw = controller_worker.ControllerWorker() cw.services_controller.reset_mock() @@ -1432,7 +1435,8 @@ class TestControllerWorker(base.TestCase): constants.LOADBALANCER: mock_provider_lb.to_dict(), constants.LOADBALANCER_ID: LB_ID, constants.SERVER_GROUP_ID: SERVER_GROUP_ID, - constants.VIP: mock_lb.vip.to_dict()} + constants.VIP: mock_lb.vip.to_dict(), + constants.AMPHORA_ID: AMP_ID} cw = controller_worker.ControllerWorker() cw.services_controller.reset_mock() @@ -1488,7 +1492,8 @@ class TestControllerWorker(base.TestCase): constants.LOADBALANCER: mock_provider_lb.to_dict(), constants.LOADBALANCER_ID: LB_ID, constants.SERVER_GROUP_ID: None, - constants.VIP: mock_lb.vip.to_dict()} + constants.VIP: mock_lb.vip.to_dict(), + constants.AMPHORA_ID: AMP_ID} mock_get_flavor_meta.return_value = {'taste': 'spicy'} cw = controller_worker.ControllerWorker() @@ -1544,7 +1549,8 @@ class TestControllerWorker(base.TestCase): constants.LOADBALANCER: mock_provider_lb.to_dict(), constants.LOADBALANCER_ID: LB_ID, constants.SERVER_GROUP_ID: None, - constants.VIP: mock_lb.vip.to_dict()} + constants.VIP: mock_lb.vip.to_dict(), + constants.AMPHORA_ID: AMP_ID} mock_get_az_meta.return_value = {'planet': 'jupiter'} cw = controller_worker.ControllerWorker() @@ -1635,7 +1641,8 @@ class TestControllerWorker(base.TestCase): constants.LOADBALANCER: None, constants.LOADBALANCER_ID: None, constants.SERVER_GROUP_ID: None, - constants.VIP: {}} + constants.VIP: {}, + constants.AMPHORA_ID: AMP_ID} cw = controller_worker.ControllerWorker() cw.services_controller.reset_mock()