Don't log success cleaning if ansible fails
If ansible fails cleaning, it's log "Ansible completed cleaning ...", the reason - missing 'else' statement. Change-Id: I418012daeb7377b3dad983bb17e06317b623bb22
This commit is contained in:
parent
6718d638eb
commit
52dac91217
|
@ -613,9 +613,10 @@ class AnsibleDeploy(base.DeployInterface):
|
||||||
"on node %(node)s."), {
|
"on node %(node)s."), {
|
||||||
'node': node.uuid, 'step': stepname})
|
'node': node.uuid, 'step': stepname})
|
||||||
manager_utils.cleaning_error_handler(task, six.text_type(e))
|
manager_utils.cleaning_error_handler(task, six.text_type(e))
|
||||||
LOG.info(_LI('Ansible completed cleaning step %(step)s '
|
else:
|
||||||
'on node %(node)s.'),
|
LOG.info(_LI('Ansible completed cleaning step %(step)s '
|
||||||
{'node': node.uuid, 'step': stepname})
|
'on node %(node)s.'),
|
||||||
|
{'node': node.uuid, 'step': stepname})
|
||||||
|
|
||||||
def prepare_cleaning(self, task):
|
def prepare_cleaning(self, task):
|
||||||
"""Boot into the ramdisk to prepare for cleaning.
|
"""Boot into the ramdisk to prepare for cleaning.
|
||||||
|
|
|
@ -583,6 +583,26 @@ class TestAnsibleDeploy(db_base.DbTestCase):
|
||||||
task.node, action='clean')
|
task.node, action='clean')
|
||||||
self.assertFalse(run_playbook_mock.called)
|
self.assertFalse(run_playbook_mock.called)
|
||||||
|
|
||||||
|
@mock.patch.object(ansible_deploy, '_parse_ansible_driver_info',
|
||||||
|
return_value=('test_pl', 'test_u', 'test_k'),
|
||||||
|
autospec=True)
|
||||||
|
@mock.patch.object(utils, 'cleaning_error_handler', autospec=True)
|
||||||
|
@mock.patch.object(ansible_deploy, '_run_playbook', autospec=True)
|
||||||
|
@mock.patch.object(ansible_deploy, 'LOG', autospec=True)
|
||||||
|
def test_execute_clean_step_no_success_log(
|
||||||
|
self, log_mock, run_mock, utils_mock, parse_driver_info_mock):
|
||||||
|
|
||||||
|
run_mock.side_effect = exception.InstanceDeployFailure('Boom')
|
||||||
|
step = {'priority': 10, 'interface': 'deploy',
|
||||||
|
'step': 'erase_devices', 'args': {'tags': ['clean']}}
|
||||||
|
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||||
|
self.driver.execute_clean_step(task, step)
|
||||||
|
log_mock.error.assert_called_once_with(
|
||||||
|
mock.ANY, {'node': task.node['uuid'],
|
||||||
|
'step': 'erase_devices'})
|
||||||
|
utils_mock.assert_called_once_with(task, 'Boom')
|
||||||
|
self.assertFalse(log_mock.info.called)
|
||||||
|
|
||||||
@mock.patch.object(ansible_deploy, '_run_playbook', autospec=True)
|
@mock.patch.object(ansible_deploy, '_run_playbook', autospec=True)
|
||||||
@mock.patch.object(utils, 'set_node_cleaning_steps', autospec=True)
|
@mock.patch.object(utils, 'set_node_cleaning_steps', autospec=True)
|
||||||
@mock.patch.object(utils, 'node_power_action', autospec=True)
|
@mock.patch.object(utils, 'node_power_action', autospec=True)
|
||||||
|
|
Loading…
Reference in New Issue