Fix output of `st2 execution get <id> -j`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.5k
- Forks
- 787
- PR merge metrics
- No merged PRs in 30d
Description
In https://github.com/StackStorm/st2tests/pull/121, I had to write a few extra hacky steps to parse output of st2 execution get, because I was having issues parsing the output from the -j flag:
~$ st2 run examples.mistral-basic cmd=date
..
id: 5a31e81d32ed352825f47f77
action.ref: examples.mistral-basic
parameters:
cmd: date
status: succeeded
result_task: task1
result:
failed: false
return_code: 0
stderr: ''
stdout: Thu Dec 14 02:55:26 UTC 2017
succeeded: true
start_timestamp: Thu, 14 Dec 2017 02:55:25 UTC
end_timestamp: Thu, 14 Dec 2017 02:55:28 UTC
+--------------------------+------------------------+-------+------------+-------------------------------+
| id | status | task | action | start_timestamp |
+--------------------------+------------------------+-------+------------+-------------------------------+
| 5a31e81d32ed352825f47f7a | succeeded (1s elapsed) | task1 | core.local | Thu, 14 Dec 2017 02:55:25 UTC |
+--------------------------+------------------------+-------+------------+-------------------------------+
~$ st2 execution get 5a31e81d32ed352825f47f77 -j
{
"action": {
"ref": "examples.mistral-basic"
},
"end_timestamp": "2017-12-14T02:55:28.108712Z",
"id": "5a31e81d32ed352825f47f77",
"parameters": {
"cmd": "date"
},
"result": {
"failed": false,
"return_code": 0,
"stderr": "",
"stdout": "Thu Dec 14 02:55:26 UTC 2017",
"succeeded": true
},
"result_task": "task1",
"start_timestamp": "2017-12-14T02:55:25.087795Z",
"status": "succeeded"
}
[
{
"action": "core.local",
"id": "5a31e81d32ed352825f47f7a",
"start_timestamp": "2017-12-14T02:55:25.711121Z",
"status": "succeeded (1s elapsed)",
"task": "task1"
}
]
The output isn't valid JSON, so I couldn't directly use the asserts pack to parse the output. I had to use an intermediate step. This is invalid because it's both an object and a list next to each other. The object is the details of the execution, the list is the details of the subexecutions. This is kind of useful but only if presented in the right way.
I'd suggest either a flag to hide the list, or nest the list inside the object under a "subexecutions" key (the latter of which is breaking).
TODO
- Ensure the output of
st2 execution get <id> -jproduces valid JSON that can be safely read by other tools - Change the inquiry tests in https://github.com/StackStorm/st2tests so that these hacky steps aren't included
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the st2 execution get <id> -j command and the inquiry tests in the linked st2tests pull request. Reproduce the output shown in this issue and inspect how the execution details and subexecution list are emitted. Done means the command produces valid JSON that other tools can parse directly, with the subexecutions represented consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100