Browse Source

Fix LB set in ERROR too early in MapLoadbalancerToAmphora

This is a follow up patch for I48b0f5a773209b1c1b056d71c0da05d6fd82ca73,
this fix applies only on Wallaby and older releases because the code was
removed during the Xena cycle.

It removes calls to mark_loadbalancer_prov_status_error in revert method
of tasks (except in LoadBalancer*ToErrorOnRevertTask)

Story 2009651
Task 43810
Story 2009652
Task 43811

Change-Id: I7692155fb113442b692267ab12b69ab90200bcb5
(cherry picked from commit 9b7791db52)
(cherry picked from commit de20868ab7)
changes/29/820329/1
Gregory Thiemonge 6 months ago
parent
commit
0d25fe5fff
  1. 5
      octavia/controller/worker/v1/tasks/database_tasks.py
  2. 5
      octavia/controller/worker/v2/tasks/database_tasks.py
  3. 32
      octavia/tests/unit/controller/worker/v1/tasks/test_database_tasks.py
  4. 32
      octavia/tests/unit/controller/worker/v2/tasks/test_database_tasks.py

5
octavia/controller/worker/v1/tasks/database_tasks.py

@ -551,11 +551,6 @@ class MapLoadbalancerToAmphora(BaseDatabaseTask):
return amp.id
def revert(self, result, loadbalancer_id, *args, **kwargs):
LOG.warning("Reverting Amphora allocation for the load "
"balancer %s in the database.", loadbalancer_id)
self.task_utils.mark_loadbalancer_prov_status_error(loadbalancer_id)
class _MarkAmphoraRoleAndPriorityInDB(BaseDatabaseTask):
"""Alter the amphora role and priority in DB."""

5
octavia/controller/worker/v2/tasks/database_tasks.py

@ -592,11 +592,6 @@ class MapLoadbalancerToAmphora(BaseDatabaseTask):
# loadbalancer flow can executed properly
return amp.to_dict()
def revert(self, result, loadbalancer_id, *args, **kwargs):
LOG.warning("Reverting Amphora allocation for the load "
"balancer %s in the database.", loadbalancer_id)
self.task_utils.mark_loadbalancer_prov_status_error(loadbalancer_id)
class _MarkAmphoraRoleAndPriorityInDB(BaseDatabaseTask):
"""Alter the amphora role and priority in DB."""

32
octavia/tests/unit/controller/worker/v1/tasks/test_database_tasks.py

@ -573,22 +573,6 @@ class TestDatabaseTasks(base.TestCase):
self.assertIsNone(amp_id)
# Test revert
map_lb_to_amp.revert(None, self.loadbalancer_mock.id)
repo.LoadBalancerRepository.update.assert_called_once_with(
'TEST',
id=LB_ID,
provisioning_status=constants.ERROR)
# Test revert with exception
repo.LoadBalancerRepository.update.reset_mock()
mock_loadbalancer_repo_update.side_effect = Exception('fail')
map_lb_to_amp.revert(None, self.loadbalancer_mock.id)
repo.LoadBalancerRepository.update.assert_called_once_with(
'TEST',
id=LB_ID,
provisioning_status=constants.ERROR)
@mock.patch('octavia.db.repositories.AmphoraRepository.'
'allocate_and_associate',
side_effect=[_amphora_mock, None])
@ -618,22 +602,6 @@ class TestDatabaseTasks(base.TestCase):
self.assertIsNone(amp_id)
# Test revert
map_lb_to_amp.revert(None, self.loadbalancer_mock.id)
repo.LoadBalancerRepository.update.assert_called_once_with(
'TEST',
id=LB_ID,
provisioning_status=constants.ERROR)
# Test revert with exception
repo.LoadBalancerRepository.update.reset_mock()
mock_loadbalancer_repo_update.side_effect = Exception('fail')
map_lb_to_amp.revert(None, self.loadbalancer_mock.id)
repo.LoadBalancerRepository.update.assert_called_once_with(
'TEST',
id=LB_ID,
provisioning_status=constants.ERROR)
@mock.patch('octavia.db.repositories.AmphoraRepository.get',
return_value=_amphora_mock)
@mock.patch('octavia.db.repositories.LoadBalancerRepository.get',

32
octavia/tests/unit/controller/worker/v2/tasks/test_database_tasks.py

@ -624,22 +624,6 @@ class TestDatabaseTasks(base.TestCase):
self.assertIsNone(amp_id)
# Test revert
map_lb_to_amp.revert(None, LB_ID)
repo.LoadBalancerRepository.update.assert_called_once_with(
'TEST',
id=LB_ID,
provisioning_status=constants.ERROR)
# Test revert with exception
repo.LoadBalancerRepository.update.reset_mock()
mock_loadbalancer_repo_update.side_effect = Exception('fail')
map_lb_to_amp.revert(None, LB_ID)
repo.LoadBalancerRepository.update.assert_called_once_with(
'TEST',
id=LB_ID,
provisioning_status=constants.ERROR)
@mock.patch('octavia.db.repositories.AmphoraRepository.'
'allocate_and_associate',
side_effect=[_db_amphora_mock, None])
@ -669,22 +653,6 @@ class TestDatabaseTasks(base.TestCase):
self.assertIsNone(amp)
# Test revert
map_lb_to_amp.revert(None, _db_loadbalancer_mock.id)
repo.LoadBalancerRepository.update.assert_called_once_with(
'TEST',
id=LB_ID,
provisioning_status=constants.ERROR)
# Test revert with exception
repo.LoadBalancerRepository.update.reset_mock()
mock_loadbalancer_repo_update.side_effect = Exception('fail')
map_lb_to_amp.revert(None, _db_loadbalancer_mock.id)
repo.LoadBalancerRepository.update.assert_called_once_with(
'TEST',
id=LB_ID,
provisioning_status=constants.ERROR)
@mock.patch('octavia.db.repositories.AmphoraRepository.get',
return_value=_db_amphora_mock)
@mock.patch('octavia.db.repositories.LoadBalancerRepository.get',

Loading…
Cancel
Save