Set node to the error if reapply fails
Setting node to the error status with error message if reapply fails to get introspection data from swift. Change-Id: Idccb68847d14d5050c735facf3da7b3ec108adbe Closes-Bug: #1618833
This commit is contained in:
parent
d970bf56da
commit
f29a71f576
@ -376,11 +376,14 @@ def _reapply(node_info):
|
|||||||
# runs in background
|
# runs in background
|
||||||
try:
|
try:
|
||||||
introspection_data = _get_unprocessed_data(node_info.uuid)
|
introspection_data = _get_unprocessed_data(node_info.uuid)
|
||||||
except Exception:
|
except Exception as exc:
|
||||||
LOG.exception(_LE('Encountered exception while fetching '
|
LOG.exception(_LE('Encountered exception while fetching '
|
||||||
'stored introspection data'),
|
'stored introspection data'),
|
||||||
node_info=node_info)
|
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
|
return
|
||||||
|
|
||||||
failures = []
|
failures = []
|
||||||
|
@ -656,6 +656,8 @@ class TestReapplyNode(BaseTest):
|
|||||||
swift_mock, apply_mock,
|
swift_mock, apply_mock,
|
||||||
post_hook_mock, ):
|
post_hook_mock, ):
|
||||||
exc = Exception('Oops')
|
exc = Exception('Oops')
|
||||||
|
expected_error = ('Unexpected exception Exception while fetching '
|
||||||
|
'unprocessed introspection data from Swift: Oops')
|
||||||
swift_mock.get_object.side_effect = exc
|
swift_mock.get_object.side_effect = exc
|
||||||
with mock.patch.object(process.LOG, 'exception',
|
with mock.patch.object(process.LOG, 'exception',
|
||||||
autospec=True) as log_mock:
|
autospec=True) as log_mock:
|
||||||
@ -669,7 +671,8 @@ class TestReapplyNode(BaseTest):
|
|||||||
self.assertFalse(swift_mock.create_object.called)
|
self.assertFalse(swift_mock.create_object.called)
|
||||||
self.assertFalse(apply_mock.called)
|
self.assertFalse(apply_mock.called)
|
||||||
self.assertFalse(post_hook_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
|
@prepare_mocks
|
||||||
def test_prehook_failure(self, finished_mock, swift_mock,
|
def test_prehook_failure(self, finished_mock, swift_mock,
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
fixes:
|
||||||
|
- Set the node to the error state when it
|
||||||
|
failed get data from swift.
|
Loading…
Reference in New Issue
Block a user