Bug 1899525 - Reporting commands ignore --reportformat json option in lvm shell
Summary: Reporting commands ignore --reportformat json option in lvm shell
Keywords:
Status: POST
Alias: None
Product: LVM and device-mapper
Classification: Community
Component: lvm2
Version: unspecified
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
: ---
Assignee: Peter Rajnoha
QA Contact: cluster-qe
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-11-19 13:38 UTC by Peter Rajnoha
Modified: 2023-08-10 15:40 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Embargoed:
pm-rhel: lvm-technical-solution?
pm-rhel: lvm-test-coverage?


Attachments (Terms of Use)

Description Peter Rajnoha 2020-11-19 13:38:45 UTC
When running lvm commands inside lvm shell, the --reportformat option is ignored:

❯ lvm
lvm> pvs --reportformat json
  PV         VG     Fmt  Attr PSize   PFree  
  /dev/sda   vg     lvm2 a--  124.00m 124.00m
  /dev/sdb   vg     lvm2 a--  124.00m 124.00m
  /dev/sdc   vg     lvm2 a--  124.00m 124.00m
  /dev/vda3  fedora lvm2 a--  <18.00g      0 

The same works if executed from command line directly:

❯ pvs --reportformat json
  {
      "report": [
          {
              "pv": [
                  {"pv_name":"/dev/sda", "vg_name":"vg", "pv_fmt":"lvm2", "pv_attr":"a--", "pv_size":"124.00m", "pv_free":"124.00m"},
                  {"pv_name":"/dev/sdb", "vg_name":"vg", "pv_fmt":"lvm2", "pv_attr":"a--", "pv_size":"124.00m", "pv_free":"124.00m"},
                  {"pv_name":"/dev/sdc", "vg_name":"vg", "pv_fmt":"lvm2", "pv_attr":"a--", "pv_size":"124.00m", "pv_free":"124.00m"},
                  {"pv_name":"/dev/vda3", "vg_name":"fedora", "pv_fmt":"lvm2", "pv_attr":"a--", "pv_size":"<18.00g", "pv_free":"0 "}
              ]
          }
      ]
  }


I remember this worked, so it must have regressed at some point. I'll try to bisect when I have some spare time...

Comment 1 Peter Rajnoha 2022-08-26 10:40:49 UTC
I got mislead a bit - this hasn't ever been supported. We can change reportformat only for the lvm shell as a whole, not for individual command executed inside the shell. The --reportformat option was just silently ignored so I've added a check and now we error out if an unsupported argument is used.

For example:
  lvm> pvs --reportformat json
    Argument --reportformat cannot be used in interactive mode.
    Error during parsing of command line.


https://sourceware.org/git/?p=lvm2.git;a=commit;h=e6b6a09f90f53a5cea3a712b2b84af57f4514a02


Note You need to log in before you can comment on or make changes to this bug.