salt --async emitting jid and general methods of capturing it between platforms #67311
Replies: 9 comments 1 reply
-
Seems like it would make sense to have |
Beta Was this translation helpful? Give feedback.
-
Totally agreed. Yet --show-jid doesn't follow that consistency as well and since it writes to stdout, it interferes with redirection. At the risk of interfering with the output schema, does it make sense to emit an array of associative-arrays where the first element would be the jid, and the second would be the result? Or should the jid be merged into the list of minions (which has the side effect of "jid" being a minion id). Or should it be writing to stderr or allow the user to specify an alternative fd to write it to so that way it doesn't interfere with the result output? |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue. |
Beta Was this translation helpful? Give feedback.
-
Please keep this open until someone reviews the PR as they are both tied. You guys really need to use tags to prioritize PRs. |
Beta Was this translation helpful? Give feedback.
-
Thank you for updating this issue. It is no longer marked as stale. |
Beta Was this translation helpful? Give feedback.
-
i'd like this too. i tested with '--out=json' and it doesn't seem to register. if --out=json worked, it would be easy to pull out the job id with jq. |
Beta Was this translation helpful? Give feedback.
-
I haven't studied our usage but I think outputting the jid to stderr might work well: --show-jid-stderr ? |
Beta Was this translation helpful? Give feedback.
-
it should output to stdout |
Beta Was this translation helpful? Give feedback.
-
Ftr, it's not a straightforward fix because the printing of the jid is happening outside of the regular job output. That's why the --out parameter doesn't affect it. |
Beta Was this translation helpful? Give feedback.
-
Description of Issue
This is not an issue, but probably a question that leads towards a feature request. When using the salt client with the
--async
(or the--show-jid
) option, extra text is emitted in order to describe to the caller what is being returned. As an example, using the--async
parameter the following message is emitted.If one wants to capture the job id from their shell, this extra text will need to be culled out through some means. For some shells, such as on a bourne-like shell they'll need to combine it with other commands like in the following:
If using the windows command prompt, one'll probably use something similar to the following to extract the job id.
Then Powershell which might be considered simpler by some...
However, If one uses the
--show-jid
option, the--out=quiet
parameter can be passed as in the following which makes capturing a little simpler perhaps.One minor issue of
--show-jid
is that the job id is being emitted in a hardcoded format (can't convert to json/yaml/etc. w/ an outputter). Ftr the format of this is atsalt/client/__init__.py:990
. The primary issue with this, however, is that it appears that this format is unable to be combined with--async
in order to run a job in the background which makes it not possible for saving the jid for a long-running job.So...Is there some way to make the salt client emit just the job id and nothing else? If not, would you guys accept a PR for something like a
-j
option that emits just the job-id? This way scripters can simply just assign the job id for a job to a variable (generally) across platforms.Rather than emitting the job-id by considering another parameter, perhaps the regular output of
--async
could be split across stdout+stderr so its simpler to capture the job id by discarding stderr.Or perhaps another (more consistent?) way would be to feed the output of the job id from
--async
through the outputter that was specified. This way one can include a minimalistic outputter that emits just the jid, and specify--async --out=my-jid-emitter
if they desire that particular capability.Ftr, the line of code that (explicitly) emits the async job id is at
salt/cli/salt.py:153
.salt/salt/cli/salt.py
Lines 153 to 157 in be9879c
Setup
Not really relevant.
Steps to Reproduce Issue
Please see description.
Versions Report
Since 2015.5
Beta Was this translation helpful? Give feedback.
All reactions