Don't ignore failures when delete nodes
Deleting nodes ignore failures and just prints the results which nodes are deleted and which are failed. But in case failure it doesn't propagate exception further, as result success command execution, return code of cmd is 0. Closes-Bug: #1552224 Change-Id: I48be1d1ddf199b75cd09f6df6bdff5fef2f24334
This commit is contained in:
parent
26df6c3c37
commit
6a59a30961
@ -86,7 +86,8 @@ class NodeShellTest(utils.BaseTestCase):
|
|||||||
args = mock.MagicMock()
|
args = mock.MagicMock()
|
||||||
args.node = ['node_uuid1', 'node_uuid2']
|
args.node = ['node_uuid1', 'node_uuid2']
|
||||||
|
|
||||||
n_shell.do_node_delete(client_mock, args)
|
self.assertRaises(exceptions.ClientException, n_shell.do_node_delete,
|
||||||
|
client_mock, args)
|
||||||
client_mock.node.delete.assert_has_calls(
|
client_mock.node.delete.assert_has_calls(
|
||||||
[mock.call('node_uuid1'), mock.call('node_uuid2')])
|
[mock.call('node_uuid1'), mock.call('node_uuid2')])
|
||||||
|
|
||||||
|
@ -259,14 +259,21 @@ def do_node_create(cc, args):
|
|||||||
nargs='+',
|
nargs='+',
|
||||||
help="Name or UUID of the node.")
|
help="Name or UUID of the node.")
|
||||||
def do_node_delete(cc, args):
|
def do_node_delete(cc, args):
|
||||||
"""Unregister node(s) from the Ironic service."""
|
"""Unregister node(s) from the Ironic service.
|
||||||
|
|
||||||
|
:raises: ClientException, if error happens during the delete
|
||||||
|
"""
|
||||||
|
|
||||||
|
failures = []
|
||||||
for n in args.node:
|
for n in args.node:
|
||||||
try:
|
try:
|
||||||
cc.node.delete(n)
|
cc.node.delete(n)
|
||||||
print(_('Deleted node %s') % n)
|
print(_('Deleted node %s') % n)
|
||||||
except exceptions.ClientException as e:
|
except exceptions.ClientException as e:
|
||||||
print(_("Failed to delete node %(node)s: %(error)s")
|
failures.append(_("Failed to delete node %(node)s: %(error)s")
|
||||||
% {'node': n, 'error': e})
|
% {'node': n, 'error': e})
|
||||||
|
if failures:
|
||||||
|
raise exceptions.ClientException("\n".join(failures))
|
||||||
|
|
||||||
|
|
||||||
@cliutils.arg('node', metavar='<node>', help="Name or UUID of the node.")
|
@cliutils.arg('node', metavar='<node>', help="Name or UUID of the node.")
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Fixes an issue where deleting nodes ignore failures and just prints the results
|
||||||
|
which nodes are deleted and which are failed, always returning exit code of 0.
|
||||||
|
This now will return a non-zero exit code if at least one node-delete fails.
|
Loading…
Reference in New Issue
Block a user