Skip to content
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

Recommendation to prune archive is printed to stdout, breaking JSON output #137

Open
frwbr opened this issue Jan 12, 2024 · 1 comment
Open

Comments

@frwbr
Copy link

frwbr commented Jan 12, 2024

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.

[1] https://sourceware.org/git/?p=lvm2.git;a=blob;f=lib/format_text/archive.c;h=5acf0c04a;hb=38e0c7a1#l222

@zkabelac
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants