Give better output on scale failures

Currently when there's a failure during scale the output is
pprinted json that is confusing and uninstrutive

Printing the return message message attribute gives all the important
status needed from that json

Change-Id: I6e81f5812895f50209d1dc7a35c4f8fbd2447926
Partial-Bug: #1640933
This commit is contained in:
Adriano Petrich 2016-11-16 09:37:20 +00:00
parent c212fbd065
commit 37a4a6f6ae
2 changed files with 32 additions and 3 deletions

View File

@ -101,6 +101,34 @@ class TestDeleteNode(fakes.TestDeleteNode):
'nodes': ['instance1', ]
})
def test_node_delete_wrong_instance(self):
argslist = ['wrong_instance', '--templates',
'--stack', 'overcloud']
verifylist = [
('stack', 'overcloud'),
('nodes', ['wrong_instance']),
]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
self.websocket.wait_for_message.return_value = {
"status": "FAILED",
"message": """Failed to run action ERROR: Couldn't find \
following instances in stack overcloud: wrong_instance"""
}
self.assertRaises(exceptions.InvalidConfiguration,
self.cmd.take_action, parsed_args)
# Verify
self.workflow.executions.create.assert_called_once_with(
'tripleo.scale.v1.delete_node',
workflow_input={
'container': 'overcloud',
'queue_name': 'UUID4',
'nodes': ['wrong_instance', ]
})
class TestProvideNode(fakes.TestOvercloudNode):

View File

@ -14,9 +14,9 @@
# under the License.
from __future__ import print_function
import pprint
import uuid
from tripleoclient.exceptions import InvalidConfiguration
from tripleoclient.workflows import base
@ -33,8 +33,9 @@ def delete_node(clients, **workflow_input):
)
with tripleoclients.messaging_websocket(queue_name) as ws:
message = ws.wait_for_message(execution.id)
assert message['status'] == "SUCCESS", pprint.pformat(message)
rtn_message = ws.wait_for_message(execution.id)
if rtn_message['status'] != "SUCCESS":
raise InvalidConfiguration(rtn_message['message'])
def scale_down(clients, plan_name, nodes, timeout=None):