Browse Source

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
(cherry picked from commit 37a4a6f6ae)
tags/5.4.1
Adriano Petrich 2 years ago
parent
commit
58dfb5196e

+ 28
- 0
tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py View File

@@ -101,6 +101,34 @@ class TestDeleteNode(fakes.TestDeleteNode):
101 101
                 'nodes': ['instance1', ]
102 102
             })
103 103
 
104
+    def test_node_delete_wrong_instance(self):
105
+
106
+        argslist = ['wrong_instance', '--templates',
107
+                    '--stack', 'overcloud']
108
+        verifylist = [
109
+            ('stack', 'overcloud'),
110
+            ('nodes', ['wrong_instance']),
111
+        ]
112
+        parsed_args = self.check_parser(self.cmd, argslist, verifylist)
113
+
114
+        self.websocket.wait_for_message.return_value = {
115
+            "status": "FAILED",
116
+            "message": """Failed to run action ERROR: Couldn't find \
117
+                following instances in stack overcloud: wrong_instance"""
118
+        }
119
+
120
+        self.assertRaises(exceptions.InvalidConfiguration,
121
+                          self.cmd.take_action, parsed_args)
122
+
123
+        # Verify
124
+        self.workflow.executions.create.assert_called_once_with(
125
+            'tripleo.scale.v1.delete_node',
126
+            workflow_input={
127
+                'container': 'overcloud',
128
+                'queue_name': 'UUID4',
129
+                'nodes': ['wrong_instance', ]
130
+            })
131
+
104 132
 
105 133
 class TestProvideNode(fakes.TestOvercloudNode):
106 134
 

+ 4
- 3
tripleoclient/workflows/scale.py View File

@@ -14,9 +14,9 @@
14 14
 # under the License.
15 15
 from __future__ import print_function
16 16
 
17
-import pprint
18 17
 import uuid
19 18
 
19
+from tripleoclient.exceptions import InvalidConfiguration
20 20
 from tripleoclient.workflows import base
21 21
 
22 22
 
@@ -33,8 +33,9 @@ def delete_node(clients, **workflow_input):
33 33
     )
34 34
 
35 35
     with tripleoclients.messaging_websocket(queue_name) as ws:
36
-        message = ws.wait_for_message(execution.id)
37
-        assert message['status'] == "SUCCESS", pprint.pformat(message)
36
+        rtn_message = ws.wait_for_message(execution.id)
37
+        if rtn_message['status'] != "SUCCESS":
38
+            raise InvalidConfiguration(rtn_message['message'])
38 39
 
39 40
 
40 41
 def scale_down(clients, plan_name, nodes, timeout=None):

Loading…
Cancel
Save