Merge "Use correct error handler instead of calling process_event('fail')" into stable/ussuri

This commit is contained in:
Zuul 2020-10-02 22:52:11 +00:00 committed by Gerrit Code Review
commit 04888a414a
4 changed files with 25 additions and 20 deletions

View File

@ -701,13 +701,6 @@ class Ilo5Management(IloManagement):
task.node.driver_internal_info = driver_internal_info
task.node.save()
def _set_clean_failed(self, task, msg):
LOG.error("Out-of-band sanitize disk erase job failed for node "
"%(node)s. Message: '%(message)s'.",
{'node': task.node.uuid, 'message': msg})
task.node.last_error = msg
task.process_event('fail')
def _wait_for_disk_erase_status(self, node):
"""Wait for out-of-band sanitize disk erase to be completed."""
interval = CONF.ilo.oob_erase_devices_job_status_interval
@ -842,4 +835,4 @@ class Ilo5Management(IloManagement):
'ilo_disk_erase_ssd_check',
'cleaning_reboot',
'skip_current_clean_step')
self._set_clean_failed(task, ilo_exception)
manager_utils.cleaning_error_handler(task, ilo_exception)

View File

@ -72,8 +72,10 @@ class Ilo5RAID(base.RAIDInterface):
LOG.error("RAID configuration job failed for node %(node)s. "
"Message: '%(message)s'.",
{'node': task.node.uuid, 'message': msg})
task.node.last_error = msg
task.process_event('fail')
if task.node.provision_state == states.DEPLOYING:
manager_utils.deploying_error_handler(task, msg)
else:
manager_utils.cleaning_error_handler(task, msg)
def _set_driver_internal_true_value(self, task, *keys):
driver_internal_info = task.node.driver_internal_info

View File

@ -1373,8 +1373,9 @@ class Ilo5ManagementTestCase(db_base.DbTestCase):
task, erase_pattern={'ssd': 'xyz'})
@mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
@mock.patch.object(ilo_management.Ilo5Management, '_set_clean_failed')
def test_erase_devices_hdd_ilo_error(self, set_clean_failed_mock,
@mock.patch.object(manager_utils, 'cleaning_error_handler',
autospec=True)
def test_erase_devices_hdd_ilo_error(self, clean_err_handler_mock,
ilo_mock):
ilo_mock_object = ilo_mock.return_value
ilo_mock_object.get_available_disk_types.return_value = ['HDD']
@ -1393,5 +1394,4 @@ class Ilo5ManagementTestCase(db_base.DbTestCase):
task.node.driver_internal_info)
self.assertNotIn('skip_current_clean_step',
task.node.driver_internal_info)
set_clean_failed_mock.assert_called_once_with(
task, exc)
clean_err_handler_mock.assert_called_once_with(task, exc)

View File

@ -387,38 +387,48 @@ class Ilo5RAIDTestCase(db_base.DbTestCase):
self.node.save()
self._test_create_configuration_skip_root_skip_non_root()
@mock.patch.object(ilo_raid.Ilo5RAID, '_set_step_failed')
@mock.patch.object(manager_utils, 'cleaning_error_handler',
autospec=True)
@mock.patch.object(manager_utils, 'deploying_error_handler',
autospec=True)
@mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
def _test_create_configuration_ilo_error(self, ilo_mock,
set_step_failed_mock):
deploy_err_handler_mock,
clean_err_handler_mock):
ilo_mock_object = ilo_mock.return_value
exc = ilo_error.IloError('error')
ilo_mock_object.create_raid_configuration.side_effect = exc
with task_manager.acquire(self.context, self.node.uuid) as task:
task.driver.raid.create_configuration(
task, create_nonroot_volumes=False)
set_step_failed_mock.assert_called_once_with(
task,
'Failed to create raid configuration '
'on node %s' % self.node.uuid, exc)
self.assertNotIn('ilo_raid_create_in_progress',
task.node.driver_internal_info)
if task.node.clean_step:
self.assertNotIn('skip_current_clean_step',
task.node.driver_internal_info)
clean_err_handler_mock.assert_called_once_with(
task,
'Failed to create raid configuration '
'on node %s' % self.node.uuid)
else:
self.assertNotIn('skip_current_deploy_step',
task.node.driver_internal_info)
deploy_err_handler_mock.assert_called_once_with(
task,
'Failed to create raid configuration '
'on node %s' % self.node.uuid)
def test_create_configuration_ilo_error_cleaning(self):
self.node.clean_step = {'step': 'create_configuration',
'interface': 'raid'}
self.node.provision_state = states.CLEANING
self.node.save()
self._test_create_configuration_ilo_error()
def test_create_configuration_ilo_error_cleaning_deploying(self):
self.node.deploy_step = {'step': 'create_configuration',
'interface': 'raid'}
self.node.provision_state = states.DEPLOYING
self.node.save()
self._test_create_configuration_ilo_error()