Bug 1998620

Summary: pvremove should not be looking outside of the devicesfile if it's turned on
Product: Red Hat Enterprise Linux 8 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Devices, Filtering and Stacking QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: medium CC: agk, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, teigland, zkabelac
Version: 8.5   
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.14-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 15:21:57 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 2021-08-27 18:19:32 UTC
Description of problem:
[root@hayes-01 ~]# grep use_devicesfile /etc/lvm/lvm.conf
        # Configuration option devices/use_devicesfile.
        use_devicesfile = 1
[root@hayes-01 ~]# cat /etc/lvm/devices/system.devices
# LVM uses devices listed in this file.
# Created by LVM command lvmdevices pid 49338 at Fri Aug 27 13:04:21 2021
VERSION=1.1.868


[root@hayes-01 ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.
[root@hayes-01 ~]#  cat /etc/lvm/devices/system.devices
# LVM uses devices listed in this file.
# Created by LVM command pvremove pid 49469 at Fri Aug 27 13:14:54 2021
VERSION=1.1.870
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291b958138a7c80 DEVNAME=/dev/sdb1 PVID=O1fkLhlAqNP0vcGn1EuoLAqXnxqP39OW PART=1


# /dev/sdc1 is *not* in the devicesfile
[root@hayes-01 ~]# pvremove /dev/sdc1
  No PV found on device /dev/sdc1.
[root@hayes-01 ~]# pvremove -ff /dev/sdc1
  WARNING: devices to use does not include /dev/sdc1
  Labels on physical volume "/dev/sdc1" successfully wiped.


Version-Release number of selected component (if applicable):
kernel-4.18.0-333.el8    BUILT: Wed Aug 18 19:19:51 CDT 2021
lvm2-2.03.12-6.el8    BUILT: Tue Aug  3 07:23:05 CDT 2021
lvm2-libs-2.03.12-6.el8    BUILT: Tue Aug  3 07:23:05 CDT 2021

Comment 4 Corey Marthaler 2021-11-03 03:13:43 UTC
Marking Verified:Tested in the latest rpms.

kernel-4.18.0-348.4.el8.kpq0    BUILT: Wed Oct 27 15:00:32 CDT 2021
lvm2-2.03.14-1.el8    BUILT: Wed Oct 20 10:18:17 CDT 2021
lvm2-libs-2.03.14-1.el8    BUILT: Wed Oct 20 10:18:17 CDT 2021
lvm2-dbusd-2.03.14-1.el8    BUILT: Wed Oct 20 10:18:48 CDT 2021


[root@hayes-02 ~]# pvremove /dev/sdc1
  Cannot use /dev/sdc1: device is not in devices file
[root@hayes-02 ~]# pvremove -ff /dev/sdc1
  Cannot use /dev/sdc1: device is not in devices file


SCENARIO - remove_and_recreate_pv_with_missing_file_entry
Test the recreation and removal of a PV whos device file is missing, rather than re-adding the file entry (bug 1998620)
Create PV and quickly remove its devicefile entry for /dev/sdd1
creating PV on hayes-02 using device /dev/sdd1
pvcreate --yes -ff  /dev/sdd1
  Physical volume "/dev/sdd1" successfully created.
creating PV on hayes-02 using device /dev/sdc1
pvcreate --yes -ff  /dev/sdc1
  Physical volume "/dev/sdc1" successfully created.
creating PV on hayes-02 using device /dev/sdb1
pvcreate --yes -ff  /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.
creating PV on hayes-02 using device /dev/sdh1
pvcreate --yes -ff  /dev/sdh1
  Physical volume "/dev/sdh1" successfully created.
removing entry from the devices file for /dev/sdd1
1a. Attempt to remove PV without using the --force option (bug 1998620)
pvremove /dev/sdd1
pvremove properly failed due to missing devicesfile entry
1b. Attempt to remove PV by using the --force option (bug 1998620)
pvremove --yes -ff /dev/sdd1
pvremove properly failed due to missing devicesfile entry
adding entry to the devices file for /dev/sdd1
creating VG on hayes-02 using PV(s) /dev/sdd1 /dev/sdc1 /dev/sdb1 /dev/sdh1
vgcreate   df /dev/sdd1 /dev/sdc1 /dev/sdb1 /dev/sdh1
  Volume group "df" successfully created
removing entry from the devices file for /dev/sdd1
2. Attempt to recreate PV wo using the --force option
pvcreate --yes /dev/sdd1
  Can't initialize physical volume "/dev/sdd1" of volume group "df" without -ff
  /dev/sdd1: physical volume not initialized.
pvcreate properly failed due to missing devicesfile entry
3. Attempt to recreate PV by using the --force option
pvcreate --yes --ff /dev/sdd1
  Physical volume "/dev/sdd1" successfully created.
removing vg df from hayes-02
  WARNING: Couldn't find device with uuid MGHSUa-27L2-vnsL-V7KP-iC0x-EVGW-sQogP0.
  WARNING: VG df is missing PV MGHSUa-27L2-vnsL-V7KP-iC0x-EVGW-sQogP0 (last written to /dev/sdd1).
  WARNING: Couldn't find device with uuid MGHSUa-27L2-vnsL-V7KP-iC0x-EVGW-sQogP0.
  Volume group "df" successfully removed
removing pv /dev/sdd1 on hayes-02
  Labels on physical volume "/dev/sdd1" successfully wiped.
removing entry from the devices file for /dev/sdd1
removing pv /dev/sdc1 on hayes-02
  Labels on physical volume "/dev/sdc1" successfully wiped.
removing entry from the devices file for /dev/sdc1
removing pv /dev/sdb1 on hayes-02
  Labels on physical volume "/dev/sdb1" successfully wiped.
removing entry from the devices file for /dev/sdb1
removing pv /dev/sdh1 on hayes-02
  Labels on physical volume "/dev/sdh1" successfully wiped.
removing entry from the devices file for /dev/sdh1

Comment 7 Corey Marthaler 2021-11-16 18:31:59 UTC
Marking Verified in the latest rpms.

kernel-4.18.0-348.4.el8.kpq0    BUILT: Wed Oct 27 15:00:32 CDT 2021
lvm2-2.03.14-1.el8    BUILT: Wed Oct 20 10:18:17 CDT 2021
lvm2-libs-2.03.14-1.el8    BUILT: Wed Oct 20 10:18:17 CDT 2021


SCENARIO - remove_and_recreate_pv_with_missing_file_entry:  Test the recreation and removal of a PV whos device file is missing, rather than re-adding the file entry (bug 1998620)
Create PV and quickly remove its devicefile entry for /dev/sdd1
creating PV on hayes-01 using device /dev/sdd1
pvcreate --yes -ff  /dev/sdd1
WARNING: Heartbeat did not respond at start of command.  Check btimed service on remote host
  Physical volume "/dev/sdd1" successfully created.
creating PV on hayes-01 using device /dev/sdc1
pvcreate --yes -ff  /dev/sdc1
  Physical volume "/dev/sdc1" successfully created.
creating PV on hayes-01 using device /dev/sdb1
pvcreate --yes -ff  /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.
creating PV on hayes-01 using device /dev/sdh1
pvcreate --yes -ff  /dev/sdh1
  Physical volume "/dev/sdh1" successfully created.
removing entry from the devices file for /dev/sdd1
WARNING: Heartbeat did not respond at start of command.  Check btimed service on remote host
1a. Attempt to remove PV without using the --force option (bug 1998620)
pvremove /dev/sdd1
pvremove properly failed due to missing devicesfile entry
1b. Attempt to remove PV by using the --force option (bug 1998620)
pvremove --yes -ff /dev/sdd1
pvremove properly failed due to missing devicesfile entry
adding entry to the devices file for /dev/sdd1
creating VG on hayes-01 using PV(s) /dev/sdd1 /dev/sdc1 /dev/sdb1 /dev/sdh1
vgcreate   df /dev/sdd1 /dev/sdc1 /dev/sdb1 /dev/sdh1
  Volume group "df" successfully created
removing entry from the devices file for /dev/sdd1
2. Attempt to recreate PV wo using the --force option
pvcreate --yes /dev/sdd1
  Can't initialize physical volume "/dev/sdd1" of volume group "df" without -ff
  /dev/sdd1: physical volume not initialized.
pvcreate properly failed due to missing devicesfile entry
3. Attempt to recreate PV by using the --force option
pvcreate --yes --ff /dev/sdd1
  Physical volume "/dev/sdd1" successfully created.
removing vg df from hayes-01
  WARNING: Couldn't find device with uuid E45x7a-mTji-9Lfr-nP6o-hBhU-DQUY-Acf3Jp.
  WARNING: VG df is missing PV E45x7a-mTji-9Lfr-nP6o-hBhU-DQUY-Acf3Jp (last written to /dev/sdd1).
  WARNING: Couldn't find device with uuid E45x7a-mTji-9Lfr-nP6o-hBhU-DQUY-Acf3Jp.
  Volume group "df" successfully removed
removing pv /dev/sdd1 on hayes-01
  Labels on physical volume "/dev/sdd1" successfully wiped.
removing entry from the devices file for /dev/sdd1
removing pv /dev/sdc1 on hayes-01
  Labels on physical volume "/dev/sdc1" successfully wiped.
removing entry from the devices file for /dev/sdc1
removing pv /dev/sdb1 on hayes-01
  Labels on physical volume "/dev/sdb1" successfully wiped.
removing entry from the devices file for /dev/sdb1
removing pv /dev/sdh1 on hayes-01
  Labels on physical volume "/dev/sdh1" successfully wiped.
removing entry from the devices file for /dev/sdh1

Comment 9 errata-xmlrpc 2022-05-10 15:21:57 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-2022:2038