From 86a9897769466374fc5ea0629788048836a717e7 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Mon, 6 Jun 2016 17:18:05 +0200 Subject: [PATCH] Keep original error message when cleaning tear down fails Currenty we set last_error to ""Failed to tear down from cleaning for node". This change adds a real reason to it for simpler debugging. Change-Id: I57866c00f4b75cd7de8d4080716a26dea9f63759 --- ironic/conductor/manager.py | 5 +++-- ironic/tests/unit/conductor/test_manager.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ironic/conductor/manager.py b/ironic/conductor/manager.py index 8cb9ba0083..8ab608c2f1 100644 --- a/ironic/conductor/manager.py +++ b/ironic/conductor/manager.py @@ -1003,8 +1003,9 @@ class ConductorManager(base_manager.BaseConductorManager): try: task.driver.deploy.tear_down_cleaning(task) except Exception as e: - msg = (_('Failed to tear down from cleaning for node %s') - % node.uuid) + msg = (_('Failed to tear down from cleaning for node %(node)s, ' + 'reason: %(err)s') + % {'node': node.uuid, 'err': e}) LOG.exception(msg) return utils.cleaning_error_handler(task, msg, tear_down_cleaning=False) diff --git a/ironic/tests/unit/conductor/test_manager.py b/ironic/tests/unit/conductor/test_manager.py index 9f327fa8be..e02523e2f9 100644 --- a/ironic/tests/unit/conductor/test_manager.py +++ b/ironic/tests/unit/conductor/test_manager.py @@ -2058,7 +2058,7 @@ class DoNodeCleanTestCase(mgr_utils.ServiceSetUpMixin, deploy_exec_mock.return_value = None power_exec_mock.return_value = None - tear_mock.side_effect = Exception() + tear_mock.side_effect = Exception('boom') self._start_service() @@ -2088,7 +2088,8 @@ class DoNodeCleanTestCase(mgr_utils.ServiceSetUpMixin, ] self.assertEqual(power_exec_calls, power_exec_mock.call_args_list) log_mock.exception.assert_called_once_with( - 'Failed to tear down from cleaning for node {}'.format(node.uuid)) + 'Failed to tear down from cleaning for node {}, reason: boom' + .format(node.uuid)) def test__do_next_clean_step_automated_fail_in_tear_down_cleaning(self): self._do_next_clean_step_fail_in_tear_down_cleaning()