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
add JSON output support to channel programs #7281
Conversation
should probably post some sample output:
|
This is a wonderful idea, and so much simpler than json-ifying every command! |
tests/zfs-tests/tests/functional/cli_root/zfs_program/zfs_program_001.ksh
Outdated
Show resolved
Hide resolved
tests/zfs-tests/tests/functional/cli_root/zfs_program/zfs_program_001.ksh
Outdated
Show resolved
Hide resolved
Thanks for the reviews! I think I've addressed all the feedback in comments or in the code, let me know if there is anything else.
|
@alek-p when it's convenient a rebase on master will sort out the Rawhide/Kernel.org build failures. There were some ABI changes in the 4.16-rc3 kernel. |
It looks like we had one hiccup in testing on CentOS 6 where the new test case failed. I've resubmitted that build to see how reproducible it is. Here's the link: http://build.zfsonlinux.org/builders/CentOS%206%20x86_64%20%28TEST%29/builds/2119 |
Just one comment. You can believe me now, or believe me later. |
seems like the test failure has to do with how python on centos 6 outputs json. I'll add some debug print into the test so that I can look into this more |
tests/zfs-tests/tests/functional/cli_root/zfs_program/zfs_program_json.ksh
Outdated
Show resolved
Hide resolved
tests/zfs-tests/tests/functional/cli_root/zfs_program/zfs_program_json.ksh
Outdated
Show resolved
Hide resolved
Signed-off-by: Alek Pinchuk <apinchuk@datto.com>
Codecov Report
@@ Coverage Diff @@
## master #7281 +/- ##
==========================================
- Coverage 76.62% 76.29% -0.34%
==========================================
Files 328 329 +1
Lines 104034 104188 +154
==========================================
- Hits 79716 79489 -227
- Misses 24318 24699 +381
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally, this looks good to me but I'm no expert on the pitfalls of using JSON formatted output. Since we've had quite a lot of interest in this particular functionality it would be great if a few more people could test and approve this PR before it's merged.
@richardelling regarding you comment on formatting numbers are there specific changes you're looking for?
I'll be happy to do a |
Merged to master. Please open new PRs to extend this functionality as needed. |
In what version of ZFS does |
@RLovelett it's currently only in master. We haven't pushed it to a point release yet since it's such a big patch. We may push it to a future point release if we're comfortable enough with it. Otherwise, it will be supported in 0.8.0. |
This patch adds JSON output support to channel programs.
Description
The changes piggyback JSON output support on top of channel programs (#6558). This way the JSON output support is targeted to scripting use cases and is easily maintainable since it really only touches one function (
zfs_do_channel_program()
).This patch ports Joyent's JSON nvlist library from illumos to enable easy JSON printing of channel program output nvlist.
To keep the delta small I also took advantage of the fact that printing in
zfs_do_channel_program()
was almost always done before exiting the program.Motivation and Context
There have been requests to add JSON output support for a while, since as far back as 2012. See #3938, #740, and #6967
How Has This Been Tested?
Unit testing along with the newly added test case.
Types of changes
Checklist:
Signed-off-by
.