Browse Source

Fix batch member create for v1 amphora driver

A previous patch[1] missed batch_member_update when adding database
repository "get" method retries for new object creation actions.
This patch fixes batch member create to retry the database get call
when new members are being created via batch member update.
This issue only impacts the v1 amphora driver as the v2 driver
does not need to get these objects from the database.

Story: 2007581
Task: 39503

[1] 48e85569f7

Change-Id: Ia3476ab7b24dc3fd6e29ff2abe6eb6bacd9908ed
tags/4.1.3^0
Michael Johnson 2 months ago
committed by Hemanth Nakkina
parent
commit
d2bef9a47c
2 changed files with 16 additions and 3 deletions
  1. +13
    -2
      octavia/controller/worker/controller_worker.py
  2. +3
    -1
      octavia/tests/unit/controller/worker/test_controller_worker.py

+ 13
- 2
octavia/controller/worker/controller_worker.py View File

@@ -457,12 +457,23 @@ class ControllerWorker(base_taskflow.BaseTaskFlowEngine):
log=LOG):
delete_member_tf.run()

@tenacity.retry(
retry=tenacity.retry_if_exception_type(db_exceptions.NoResultFound),
wait=tenacity.wait_incrementing(
RETRY_INITIAL_DELAY, RETRY_BACKOFF, RETRY_MAX),
stop=tenacity.stop_after_attempt(RETRY_ATTEMPTS))
def batch_update_members(self, old_member_ids, new_member_ids,
updated_members):
old_members = [self._member_repo.get(db_apis.get_session(), id=mid)
for mid in old_member_ids]
new_members = [self._member_repo.get(db_apis.get_session(), id=mid)
for mid in new_member_ids]
# The API may not have commited all of the new member records yet.
# Make sure we retry looking them up.
if None in new_members or len(new_members) != len(new_member_ids):
LOG.warning('Failed to fetch one of the new members from DB. '
'Retrying for up to 60 seconds.')
raise db_exceptions.NoResultFound
old_members = [self._member_repo.get(db_apis.get_session(), id=mid)
for mid in old_member_ids]
updated_members = [
(self._member_repo.get(db_apis.get_session(), id=m.get('id')), m)
for m in updated_members]


+ 3
- 1
octavia/tests/unit/controller/worker/test_controller_worker.py View File

@@ -824,7 +824,8 @@ class TestControllerWorker(base.TestCase):
mock_amp_repo_get):

_flow_mock.reset_mock()

mock_member_repo_get.side_effect = [None, _member_mock,
_member_mock, _member_mock]
cw = controller_worker.ControllerWorker()
cw.batch_update_members([9], [11], [MEMBER_UPDATE_DICT])

@@ -837,6 +838,7 @@ class TestControllerWorker(base.TestCase):
constants.POOL: _pool_mock}))

_flow_mock.run.assert_called_once_with()
self.assertEqual(4, mock_member_repo_get.call_count)

@mock.patch('octavia.controller.worker.flows.'
'pool_flows.PoolFlows.get_create_pool_flow',


Loading…
Cancel
Save