Merge "Set node to the error if reapply fails"

This commit is contained in:
Jenkins 2016-09-12 11:26:13 +00:00 committed by Gerrit Code Review
commit a35cb10896
3 changed files with 12 additions and 3 deletions

View File

@ -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 = []

View File

@ -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,

View File

@ -0,0 +1,3 @@
fixes:
- Set the node to the error state when it
failed get data from swift.