diff --git a/ironic_inspector/process.py b/ironic_inspector/process.py index 083fee486..7c8e90f8b 100644 --- a/ironic_inspector/process.py +++ b/ironic_inspector/process.py @@ -376,11 +376,14 @@ def _reapply(node_info): # runs in background try: introspection_data = _get_unprocessed_data(node_info.uuid) - except Exception: + except Exception as exc: LOG.exception(_LE('Encountered exception while fetching ' 'stored introspection data'), node_info=node_info) - node_info.release_lock() + msg = (_('Unexpected exception %(exc_class)s while fetching ' + 'unprocessed introspection data from Swift: %(error)s') % + {'exc_class': exc.__class__.__name__, 'error': exc}) + node_info.finished(error=msg) return failures = [] diff --git a/ironic_inspector/test/unit/test_process.py b/ironic_inspector/test/unit/test_process.py index 858e097e0..63fbb080f 100644 --- a/ironic_inspector/test/unit/test_process.py +++ b/ironic_inspector/test/unit/test_process.py @@ -653,6 +653,8 @@ class TestReapplyNode(BaseTest): swift_mock, apply_mock, post_hook_mock, ): exc = Exception('Oops') + expected_error = ('Unexpected exception Exception while fetching ' + 'unprocessed introspection data from Swift: Oops') swift_mock.get_object.side_effect = exc with mock.patch.object(process.LOG, 'exception', autospec=True) as log_mock: @@ -666,7 +668,8 @@ class TestReapplyNode(BaseTest): self.assertFalse(swift_mock.create_object.called) self.assertFalse(apply_mock.called) self.assertFalse(post_hook_mock.called) - self.assertFalse(finished_mock.called) + finished_mock.assert_called_once_with(self.node_info, + expected_error) @prepare_mocks def test_prehook_failure(self, finished_mock, swift_mock, diff --git a/releasenotes/notes/set-node-to-error-when-swift-failure-3e919ecbf9db6401.yaml b/releasenotes/notes/set-node-to-error-when-swift-failure-3e919ecbf9db6401.yaml new file mode 100644 index 000000000..e1232a060 --- /dev/null +++ b/releasenotes/notes/set-node-to-error-when-swift-failure-3e919ecbf9db6401.yaml @@ -0,0 +1,3 @@ +fixes: + - Set the node to the error state when it + failed get data from swift.