Stdout poisoning in knife commands


#1

Hi,

So a big problem I keep running into with knife, as I move away from
habitual chef-solo/chef-zero use and into an environment with a Chef
server, is a lot of stdout poisoning from these commands. It’s very
nonstandard for something like ‘knife search’ to emit unrelated text, such
as “N items found”, on stdout. It makes it much harder than it needs or, to
be honest, ought to be to work with Chef, and it’s a real drag. Are there
any plans for better stdout/stderr discipline during the Chef 12 lifecycle?

Thanks,
Ed


#2

what exactly you are trying to achieve? most of us find those output very
useful (and a vast majority of these features came after user feedback). If
you are trying to extend knife from CLI directly (that shell route i
assume), you can use the -Fj flag to format your stuff into json and then
use json parsing CLI to format whatever you want.

Note, you can extend knife very easily using the plugin mechanism, this
gives you better control, as well as you can reuse other plugins.

Lastly, if you think an ability to spit out the information as stream,
which will facilitate | style chaining from command line, you can raise
an RFC, and we can work on that, and have an uniform record - line based
output across knife plugins. This will involve writing another formatter
for core knife (which is not hard, given knife has the whole formatter
mechanism anyway).

[1]https://docs.chef.io/plugin_knife_custom.html

On Wed, Feb 25, 2015 at 9:15 AM, Ed Ropple eropple@leaf.me wrote:

Hi,

So a big problem I keep running into with knife, as I move away from
habitual chef-solo/chef-zero use and into an environment with a Chef
server, is a lot of stdout poisoning from these commands. It’s very
nonstandard for something like ‘knife search’ to emit unrelated text, such
as “N items found”, on stdout. It makes it much harder than it needs or, to
be honest, ought to be to work with Chef, and it’s a real drag. Are there
any plans for better stdout/stderr discipline during the Chef 12 lifecycle?

Thanks,
Ed


#3

“Parse with JSON” is not a friendly option. It’s not a streaming nor a
row-based format. -Ftext is a streaming format, but poisons stdout in a
way that is antithetical to normal Unix usage.

I filed an issue describing the issue:

-Ed

On Wed, Feb 25, 2015 at 2:19 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

what exactly you are trying to achieve? most of us find those output very
useful (and a vast majority of these features came after user feedback). If
you are trying to extend knife from CLI directly (that shell route i
assume), you can use the -Fj flag to format your stuff into json and then
use json parsing CLI to format whatever you want.

Note, you can extend knife very easily using the plugin mechanism, this
gives you better control, as well as you can reuse other plugins.

Lastly, if you think an ability to spit out the information as stream,
which will facilitate | style chaining from command line, you can raise
an RFC, and we can work on that, and have an uniform record - line based
output across knife plugins. This will involve writing another formatter
for core knife (which is not hard, given knife has the whole formatter
mechanism anyway).

[1]https://docs.chef.io/plugin_knife_custom.html

On Wed, Feb 25, 2015 at 9:15 AM, Ed Ropple eropple@leaf.me wrote:

Hi,

So a big problem I keep running into with knife, as I move away from
habitual chef-solo/chef-zero use and into an environment with a Chef
server, is a lot of stdout poisoning from these commands. It’s very
nonstandard for something like ‘knife search’ to emit unrelated text, such
as “N items found”, on stdout. It makes it much harder than it needs or, to
be honest, ought to be to work with Chef, and it’s a real drag. Are there
any plans for better stdout/stderr discipline during the Chef 12 lifecycle?

Thanks,
Ed


#4

On Wednesday, February 25, 2015 at 11:31 AM, Ed Ropple wrote:

“Parse with JSON” is not a friendly option. It’s not a streaming nor a row-based format. -Ftext is a streaming format, but poisons stdout in a way that is antithetical to normal Unix usage.

I filed an issue describing the issue: https://github.com/chef/chef/issues/2980

-Ed
I replied on the issue. tl;dr, -Ftext isn’t a row-based format either, as you can demonstrate with knife node show NODE -m. I would be fine with moving “diagnostic” messages like that to stderr to make what you’re doing now easier, but there’s a limit to what you can accomplish with the “text” formatter because first and foremost it’s about presenting data for humans to read, which is IMO not feasible to do in a row-based format given the nested JSON structures we’re dealing with.


Daniel DeLeo