-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Send show_jid output to stderr #67955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
When using --out=json, all data sent to stdout should be valid JSON to allow for piping into processing tools such as `jq`. Make this the case with "show_jid" being enabled as well, by printing the JID line to stderr instead of stdout. Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
I tried adding tests with
in tests/pytests/integration/cli/test_salt.py and also attempted a few variations of placing the
Can I get regular / unfiltered CLI output in the test suite somehow? |
this isn't really how you want to go about fixing this. salt.client really shouldn't be printing to stdout or stderr at all, but that's just an unfortunate side effect of how someone wrote this originally. you really want something like this:
can you explore testing this patch and updating your PR? |
Hi @mattp-, thanks for your input and the better solution - I will test, but from briefly reading over your patch, it seems it would cause the jid to not be printed at all if operating with the json or yaml output mode? I understand why, however think it would still be useful to have it available - maybe at least for JSON mode, should we print it as a separate JSON object? |
no, it would. implicitly the jid is in the 'full_return'/raw load returned over the wire; i should have pasted an output example:
|
What does this PR do?
When using --out=json, all data sent to stdout should be valid JSON to allow for piping into processing tools such as
jq
. Make this the case with "show_jid" being enabled as well, by printing the JID line to stderr instead of stdout.What issues does this PR fix or reference?
Fixes #25154 (the issue was closed with
--static
being suggested as a solution, however this to me is merely a workaround, as it makes for a different output strategy).Previous Behavior
With
show_jid
enabled, piping into JSON processing tools leads to parsing exceptions.New Behavior
stdout can be processed as JSON with
show_jid
enabled, the same way as withshow_jid
disabled.Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes