Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2095040

Summary: 'lvmconfig --typeconfig current' should show what LVM/kernel is operating with currently
Product: Red Hat Enterprise Linux 9 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: Peter Rajnoha <prajnoha>
lvm2 sub component: Configuration files QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: unspecified CC: agk, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, zkabelac
Version: 9.1Keywords: Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.17-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 08:23:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Corey Marthaler 2022-06-08 20:22:50 UTC
Description of problem:
While rewriting some of our older tools' lvm.conf searches, I found there's really not an easy way to get the current lvm.conf value from the new tool lvmconfig. I have to first see if the value was user set (may or may not be non default), and if not, then check the default value. This is because 'lvmconfig --typeconfig current' will only show values that were set by the user.


# Here I manually set raid_fault_policy to "allocate"
[root@hayes-03 ~]# lvmconfig --typeconfig default activation/raid_fault_policy
# raid_fault_policy="warn"
[root@hayes-03 ~]# lvmconfig --typeconfig current activation/raid_fault_policy
raid_fault_policy="allocate"


# Here I haven't touched raid_region_size:
[root@hayes-03 ~]# lvmconfig --typeconfig default activation/raid_region_size
# raid_region_size=2048
[root@hayes-03 ~]# lvmconfig --typeconfig current activation/raid_region_size
  Configuration node activation/raid_region_size not found


Also, using no --typeconfig flag should imo default to "current" (maybe it already does)?
[root@hayes-03 ~]# lvmconfig  activation/raid_fault_policy
raid_fault_policy="allocate"
[root@hayes-03 ~]# lvmconfig  activation/raid_region_size
  Configuration node activation/raid_region_size not found



Version-Release number of selected component (if applicable):
lvm2-2.03.16-1.el9    BUILT: Wed May 18 12:08:33 PM CDT 2022
lvm2-libs-2.03.16-1.el9    BUILT: Wed May 18 12:08:33 PM CDT 2022

Comment 1 Corey Marthaler 2022-06-08 20:56:32 UTC
Would it also be able to just return the value asked for, so there's nothing to parse?

# lvmconfig --typeconfig default activation/raid_fault_policy
warn

Comment 2 Peter Rajnoha 2022-06-09 08:41:54 UTC
(In reply to Corey Marthaler from comment #0)
> Description of problem:
> While rewriting some of our older tools' lvm.conf searches, I found there's
> really not an easy way to get the current lvm.conf value from the new tool
> lvmconfig. I have to first see if the value was user set (may or may not be
> non default), and if not, then check the default value. This is because
> 'lvmconfig --typeconfig current' will only show values that were set by the
> user.
> 
> 
> # Here I manually set raid_fault_policy to "allocate"
> [root@hayes-03 ~]# lvmconfig --typeconfig default
> activation/raid_fault_policy
> # raid_fault_policy="warn"
> [root@hayes-03 ~]# lvmconfig --typeconfig current
> activation/raid_fault_policy
> raid_fault_policy="allocate"
> 
> 
> # Here I haven't touched raid_region_size:
> [root@hayes-03 ~]# lvmconfig --typeconfig default activation/raid_region_size
> # raid_region_size=2048
> [root@hayes-03 ~]# lvmconfig --typeconfig current activation/raid_region_size
>   Configuration node activation/raid_region_size not found
> 

Yes, '--typeconfig current' prints only the ones which are explicitly set in the config. If the setting is commented out/not set at all, it's not printed ("not found").

I think you're looking for "--typeconfig full" that should print the config as it is really used by LVM, either it is taking the explicitly set value or default value (including the scenario where the value is commented out/not set at all). So 'full' always tries to give a value for the setting if possible - the only exception are settings which simply do not have any default values defined at all (they're "NULL") - there are some of those too, see "lvmconfig --type full --withcomments" and look for the ones with "This configuration option does not have a default value defined." comment.

> 
> Also, using no --typeconfig flag should imo default to "current" (maybe it
> already does)?
> [root@hayes-03 ~]# lvmconfig  activation/raid_fault_policy
> raid_fault_policy="allocate"
> [root@hayes-03 ~]# lvmconfig  activation/raid_region_size
>   Configuration node activation/raid_region_size not found
> 

Yup, default for "--typeconfig" is "current".

Comment 3 Peter Rajnoha 2022-06-09 08:44:13 UTC
(In reply to Corey Marthaler from comment #1)
> Would it also be able to just return the value asked for, so there's nothing
> to parse?
> 
> # lvmconfig --typeconfig default activation/raid_fault_policy
> warn

Hmm, yes, I guess we could add that easily. Though it would be another option added to the plethora of options we already have for lvmconfig :)

Comment 4 Peter Rajnoha 2022-08-17 08:52:06 UTC
I've added a new --valuesonly option to lvmconfig: https://sourceware.org/git/?p=lvm2.git;a=commit;h=b4cc28c2ef72ee022c1a03819927e31775c18676

For example:

  # lvmconfig --type full activation/raid_fault_policy
  raid_fault_policy="warn"

  # lvmconfig --type full activation/raid_fault_policy --valuesonly
  "warn"

  # my_var=$(lvmconfig --type full activation/raid_fault_policy --valuesonly)

  # echo $my_var
  "warn"

Comment 7 Corey Marthaler 2022-11-18 20:01:46 UTC
To be clear for verification, the "current" mode remains the same as in the original comment #0. To see the actual current variable, the user needs to use the "full" option. The "valuesonly" flag is also available now in the latest build.

kernel-5.14.0-176.el9    BUILT: Wed Oct 12 03:57:18 AM CDT 2022
lvm2-2.03.17-1.el9    BUILT: Thu Nov 10 10:02:16 AM CST 2022
lvm2-libs-2.03.17-1.el9    BUILT: Thu Nov 10 10:02:16 AM CST 2022



[root@hayes-03 ~]#  lvmconfig --typeconfig current activation/mirror_image_fault_policy
  Configuration node activation/mirror_image_fault_policy not found

[root@hayes-03 ~]#  lvmconfig --typeconfig full activation/mirror_image_fault_policy
mirror_image_fault_policy="remove"

[root@hayes-03 ~]# lvmconfig --typeconfig full --valuesonly activation/mirror_image_fault_policy
"remove"

[root@hayes-03 ~]# grep mirror_image_fault_policy /etc/lvm/lvm.conf
        # Configuration option activation/mirror_image_fault_policy.
        # mirror_image_fault_policy = "remove"
        mirror_image_fault_policy = allocate     # edited by QA Fri Nov 18 14:00:12 2022

[root@hayes-03 ~]# lvmconfig --typeconfig full activation/mirror_image_fault_policy
mirror_image_fault_policy="allocate"

[root@hayes-03 ~]# lvmconfig --typeconfig full --valuesonly activation/mirror_image_fault_policy
"allocate"

Comment 11 Corey Marthaler 2023-01-04 01:16:49 UTC
Marking VERIFIED in the latest rpms as well.

kernel-5.14.0-212.el9    BUILT: Tue Dec 13 03:37:26 PM CST 2022
lvm2-2.03.17-3.el9    BUILT: Wed Dec  7 10:41:40 AM CST 2022
lvm2-libs-2.03.17-3.el9    BUILT: Wed Dec  7 10:41:40 AM CST 2022

[root@hayes-03 ~]# lvmconfig --typeconfig full activation/mirror_image_fault_policy
mirror_image_fault_policy="remove"
[root@hayes-03 ~]# lvmconfig --typeconfig full --valuesonly activation/mirror_image_fault_policy
"remove"

Comment 13 errata-xmlrpc 2023-05-09 08:23:40 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (lvm2 bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2544