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 1931862

Summary: fsadm reports unbound variable when used -l <path to LV>
Product: Red Hat Enterprise Linux 7 Reporter: Lukas Herbolt <lherbolt>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
lvm2 sub component: Command-line tools QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: unspecified CC: agk, cmarthal, heinzm, jbrassow, jbyrd, jreznik, mcsontos, mjuricek, msnitzer, prajnoha, thornber, zkabelac
Version: 7.9Keywords: Triaged, ZStream
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.02.187-6.el7_9.5 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1931893 (view as bug list) Environment:
Last Closed: 2021-04-27 11:31:32 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:
Bug Depends On:    
Bug Blocks: 1931893    

Description Lukas Herbolt 2021-02-23 12:27:53 UTC
Description of problem:
When resizing fs along with LV fsadm ends up with unbound variable problem.
It came up after upgrade from:

lvm2-2.02.187-6.el7.x86_64.rpm
to

lvm2-2.02.187-6.el7_9.3.x86_64

Version-Release number of selected component (if applicable):
lvm2-2.02.187-6.el7_9.3.x86_64

How reproducible:
Always 

Steps to Reproduce:
1. install lvm2 lvm2-2.02.187-6.el7_9.3.x86_64
2. fsadm -l /dev/test/xfs 3G


Actual results:
[root@sm-x1220-3 ~]# fsadm -l resize /dev/test/xfs 8G
/usr/sbin/fsadm: line 166: LVM_BINARY: unbound variable

Expected results:
[root@sm-x1220-3 ~]# ./fsadm -l resize /dev/test/xfs 8G
Phase 1 - find and verify superblock...
        - reporting progress in intervals of 15 minutes
        - 13:15:38: verify and correct link counts - 32 of 32 allocation groups done
No modify flag set, skipping filesystem flush and exiting.
  Size of logical volume test/xfs unchanged from 8.00 GiB (2048 extents).
  Logical volume test/xfs successfully resized.


Additional info:
Note that ./fsadm in the expected result is localy extracted fsadm from:

lvm2-2.02.187-6.el7.x86_64.rpm


The behavior is caused be the -u at the line 32:
set -euE -o pipefail

Removing it will fix the issue instead of testing LVM_BINARY variable 
test the LVM:

[root@sm-x1220-3 ~]# diff -u /usr/sbin/fsadm.orig /usr/sbin/fsadm
--- /usr/sbin/fsadm.orig	2021-02-23 13:25:19.325897761 +0100
+++ /usr/sbin/fsadm	2021-02-23 13:25:51.070445375 +0100
@@ -163,7 +163,7 @@
 		_FSADM_EXTOFF=$EXTOFF
 		export _FSADM_YES _FSADM_EXTOFF
 		unset FSADM_RUNNING
-		test -n "$LVM_BINARY" && PATH=$_SAVEPATH
+		test -n "$LVM" && PATH=$_SAVEPATH
 		dry exec "$LVM" lvresize $VERB $FORCE -r -L"${NEWSIZE_ORIG}b" "$VOLUME_ORIG"
 	fi

Comment 2 Zdenek Kabelac 2021-02-23 13:27:56 UTC
Omission in testing - since internal lvm2 testing always defines this variable :(
to precisely identify binary for execution.

Correct patch is this:

diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index 2cb1fc75b..4f59cee13 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -163,7 +163,7 @@ cleanup() {
 		_FSADM_EXTOFF=$EXTOFF
 		export _FSADM_YES _FSADM_EXTOFF
 		unset FSADM_RUNNING
-		test -n "$LVM_BINARY" && PATH=$_SAVEPATH
+		test -n "${LVM_BINARY-}" && PATH=$_SAVEPATH
 		dry exec "$LVM" lvresize $VERB $FORCE -r -L"${NEWSIZE_ORIG}b" "$VOLUME_ORIG"
 	fi
 
-- 

As an instant workaround user can use:

lvresize -r -L...

or define LVM_BINARY=lvm before execution of fsadm tool

or apply given patch locally.

Comment 3 Zdenek Kabelac 2021-02-23 14:07:46 UTC
Pushed upstream stable-2.02 branch fixes here:

https://listman.redhat.com/archives/lvm-devel/2021-February/msg00124.html


and test suite fix to avoid setting LVM_BINARY and better simulate real-world usage:

https://listman.redhat.com/archives/lvm-devel/2021-February/msg00117.html

Comment 4 Lukas Herbolt 2021-02-23 14:28:47 UTC
Huh, did not know ${VARIABLE-} will fix it.

Many thanks.

Comment 12 errata-xmlrpc 2021-04-27 11:31:32 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-2021:1386