Merge "Correctly unlock amphora health on failover revert"
This commit is contained in:
commit
6a54f6ac37
@ -38,6 +38,23 @@ class TaskUtils(object):
|
||||
self.l7rule_repo = repo.L7RuleRepository()
|
||||
super(TaskUtils, self).__init__(**kwargs)
|
||||
|
||||
def unmark_amphora_health_busy(self, amphora_id):
|
||||
"""Unmark the amphora_health record busy for an amphora.
|
||||
|
||||
NOTE: This should only be called from revert methods.
|
||||
|
||||
:param amphora_id: The amphora id to unmark busy
|
||||
"""
|
||||
LOG.debug('Unmarking health monitoring busy on amphora: %s',
|
||||
amphora_id)
|
||||
try:
|
||||
self.amp_health_repo.update(db_apis.get_session(),
|
||||
amphora_id=amphora_id,
|
||||
busy=False)
|
||||
except Exception as e:
|
||||
LOG.debug('Failed to update amphora health record %(amp)s '
|
||||
'due to: %(except)s', {'amp': amphora_id, 'except': e})
|
||||
|
||||
def mark_amphora_status_error(self, amphora_id):
|
||||
"""Sets an amphora status to ERROR.
|
||||
|
||||
|
@ -33,6 +33,7 @@ class AmphoraIDToErrorOnRevertTask(BaseLifecycleTask):
|
||||
|
||||
def revert(self, amphora_id, *args, **kwargs):
|
||||
self.task_utils.mark_amphora_status_error(amphora_id)
|
||||
self.task_utils.unmark_amphora_health_busy(amphora_id)
|
||||
|
||||
|
||||
class AmphoraToErrorOnRevertTask(AmphoraIDToErrorOnRevertTask):
|
||||
|
@ -52,9 +52,12 @@ class TestLifecycleTasks(base.TestCase):
|
||||
|
||||
super(TestLifecycleTasks, self).setUp()
|
||||
|
||||
@mock.patch('octavia.controller.worker.task_utils.TaskUtils.'
|
||||
'unmark_amphora_health_busy')
|
||||
@mock.patch('octavia.controller.worker.task_utils.TaskUtils.'
|
||||
'mark_amphora_status_error')
|
||||
def test_AmphoraIDToErrorOnRevertTask(self, mock_amp_status_error):
|
||||
def test_AmphoraIDToErrorOnRevertTask(self, mock_amp_status_error,
|
||||
mock_amp_health_busy):
|
||||
|
||||
amp_id_to_error_on_revert = (lifecycle_tasks.
|
||||
AmphoraIDToErrorOnRevertTask())
|
||||
@ -68,10 +71,14 @@ class TestLifecycleTasks(base.TestCase):
|
||||
amp_id_to_error_on_revert.revert(self.AMPHORA_ID)
|
||||
|
||||
mock_amp_status_error.assert_called_once_with(self.AMPHORA_ID)
|
||||
mock_amp_health_busy.assert_called_once_with(self.AMPHORA_ID)
|
||||
|
||||
@mock.patch('octavia.controller.worker.task_utils.TaskUtils.'
|
||||
'unmark_amphora_health_busy')
|
||||
@mock.patch('octavia.controller.worker.task_utils.TaskUtils.'
|
||||
'mark_amphora_status_error')
|
||||
def test_AmphoraToErrorOnRevertTask(self, mock_amp_status_error):
|
||||
def test_AmphoraToErrorOnRevertTask(self, mock_amp_status_error,
|
||||
mock_amp_health_busy):
|
||||
|
||||
amp_to_error_on_revert = lifecycle_tasks.AmphoraToErrorOnRevertTask()
|
||||
|
||||
@ -84,6 +91,7 @@ class TestLifecycleTasks(base.TestCase):
|
||||
amp_to_error_on_revert.revert(self.AMPHORA)
|
||||
|
||||
mock_amp_status_error.assert_called_once_with(self.AMPHORA_ID)
|
||||
mock_amp_health_busy.assert_called_once_with(self.AMPHORA_ID)
|
||||
|
||||
@mock.patch('octavia.controller.worker.task_utils.TaskUtils.'
|
||||
'mark_health_mon_prov_status_error')
|
||||
|
Loading…
Reference in New Issue
Block a user