Recommendation to prune archive is printed to stdout, breaking JSON output
Closed this issue · 2 comments
If the archive for a VG is too large, vgs
prints a message that recommends pruning it to stdout [1], which breaks JSON output. Minimal reproducer (for a VG named spam
):
# for i in $(seq 8192); do vgrename spam spam2; vgrename spam2 spam; done
[...]
# rm /etc/lvm/backup/spam; vgs --report-format=json 2>/dev/null
{
"report": [
Consider pruning spam VG archive with more then 6 MiB in 8206 files (see archiving settings in lvm.conf).
{
"vg": [
{"vg_name":"spam", "pv_count":"1", "lv_count":"0", "snap_count":"0", "vg_attr":"wz--n-", "vg_size":"1020.00m", "vg_free":"1020.00m"}
]
}
]
}
Passing -qq
silences the warning, which is fine as a workaround, but printing the message to stderr instead of stdout might be nicer. What do you think?
There might be other messages being printed to stdout that cause similar problems, but I only saw this particular message so far.
We will need to consider our options here.
stderr is definitely meant for errors - and this message is not 'error' - it's a suggesting info message.
So in your case - check lvm.conf and set this: log { report_command_log = 1 }
This should separate command logging into a dedicated json section "log":
However we have noticed there are some weird stuff - so there might be possible some patch needed for correction functionality.
Question is - whether this should be a default.
Also for considering could be to recognize 'non-shell' stdout and possibly behave differently and use this separate logging in auto-detected more (i.e. = 2)
Some more options how to solve this are likely possible.
This should be resolved now with: https://gitlab.com/lvmteam/lvm2/-/merge_requests/11 (lvm v2.03.26).