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 2124970

Summary: vgimportdevices should skip incomplete VGs and only exit with an error when no devs are imported
Product: Red Hat Enterprise Linux 9 Reporter: David Teigland <teigland>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Command-line tools QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: agk, cmarthal, heinzm, jbrassow, msnitzer, prajnoha, thornber, zkabelac
Version: 9.0Keywords: Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.03.17-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2139512 (view as bug list) Environment:
Last Closed: 2023-05-09 08:23:45 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: 2139512    

Description David Teigland 2022-09-07 15:27:52 UTC
Description of problem:

If vgimportdevices --all found an incomplete VG, it would print the error and exit.  If it had created a new devices file, that file would remain but be empty. 
It should instead just skip the incomplete VG and import other complete VGs.

If vgimportdevices has created a new devices file, but exits with an error without adding any devices to the new file, then it should remove the new file before exiting.  For example, if the only VG that would have been imported is incomplete and was skipped.

If vgimportdevices does not find any devices to add (when using --all, or when importing a specific VG), then the command should exit with an error.  If any devices are added to the devices file, then the command should exit with success (even if some VGs are skipped.)

vgimportdevices should take the file lock for the devices file earlier in the command, before creating a new devices file.


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 5 Corey Marthaler 2022-11-18 16:49:08 UTC
Fix verified in the latest rpms.

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



SCENARIO - vgimportdevices_from_incomplete_vg_w_removed_entry_and_offline_device:  Test importing from incomplete VG with an offline and removed entry device (bug 2124970) 
adding entry to the devices file for /dev/sdm1
creating PV on hayes-03 using device /dev/sdm1
pvcreate --yes -ff   /dev/sdm1
  Physical volume "/dev/sdm1" successfully created.
adding entry to the devices file for /dev/sde1
creating PV on hayes-03 using device /dev/sde1
pvcreate --yes -ff   /dev/sde1
  Physical volume "/dev/sde1" successfully created.
adding entry to the devices file for /dev/sdf1
creating PV on hayes-03 using device /dev/sdf1
pvcreate --yes -ff   /dev/sdf1
  Physical volume "/dev/sdf1" successfully created.
adding entry to the devices file for /dev/sdg1
creating PV on hayes-03 using device /dev/sdg1
pvcreate --yes -ff   /dev/sdg1
  Physical volume "/dev/sdg1" successfully created.
adding entry to the devices file for /dev/sdl1
creating PV on hayes-03 using device /dev/sdl1
pvcreate --yes -ff   /dev/sdl1
  Physical volume "/dev/sdl1" successfully created.
adding entry to the devices file for /dev/sda
creating PV on hayes-03 using device /dev/sda
pvcreate --yes -ff   /dev/sda
  Physical volume "/dev/sda" successfully created.
creating VG on hayes-03 using PV(s) /dev/sdm1 /dev/sde1
vgcreate    incomplete /dev/sdm1 /dev/sde1
  Volume group "incomplete" successfully created
creating VG on hayes-03 using PV(s) /dev/sdf1 /dev/sdg1
vgcreate    complete /dev/sdf1 /dev/sdg1
  Volume group "complete" successfully created

* Removing the devicesfile completely *
pvscan
  PV /dev/sdf1   VG complete        lvm2 [<1.82 TiB / <1.82 TiB free]
  PV /dev/sdg1   VG complete        lvm2 [<1.82 TiB / <1.82 TiB free]
  PV /dev/sdm1   VG incomplete      lvm2 [<1.82 TiB / <1.82 TiB free]
  PV /dev/sde1   VG incomplete      lvm2 [446.62 GiB / 446.62 GiB free]
  PV /dev/sda                       lvm2 [446.62 GiB]
  PV /dev/sdl1                      lvm2 [<1.82 TiB]
  Total: 6 [<8.15 TiB] / in use: 4 [5.89 TiB] / in no VG: 2 [<2.26 TiB]
Disabling device sdm on hayes-03
'echo offline > /sys/block/sdm/device/state'
pvscan
  PV /dev/sdf1   VG complete        lvm2 [<1.82 TiB / <1.82 TiB free]
  PV /dev/sdg1   VG complete        lvm2 [<1.82 TiB / <1.82 TiB free]
  WARNING: Couldn't find device with uuid JnqFSS-1q3a-vKsd-RMkO-UIKM-rvYW-VxNNpk.
  WARNING: VG incomplete is missing PV JnqFSS-1q3a-vKsd-RMkO-UIKM-rvYW-VxNNpk (last written to /dev/sdm1).
  PV [unknown]   VG incomplete      lvm2 [<1.82 TiB / <1.82 TiB free]
  PV /dev/sde1   VG incomplete      lvm2 [446.62 GiB / 446.62 GiB free]
  PV /dev/sda                       lvm2 [446.62 GiB]
  PV /dev/sdl1                      lvm2 [<1.82 TiB]
  Total: 6 [<8.15 TiB] / in use: 4 [5.89 TiB] / in no VG: 2 [<2.26 TiB]

* Only devices in the complete VG are to be restored *
vgimportdevices -a
  Not importing devices for VG incomplete with missing PV JnqFSS1q3avKsdRMkOUIKMrvYWVxNNpk.
  Added 2 devices to devices file.

removing vg complete from hayes-03
  Volume group "complete" successfully removed

* No devices will be restored with just the incomplete VG remaining*
vgimportdevices -a
  Not importing devices for VG incomplete with missing PV JnqFSS1q3avKsdRMkOUIKMrvYWVxNNpk.

Enabling device sdm on hayes-03
'echo running > /sys/block/sdm/device/state'
Verify that all removed devices file entries can be recreated using vgimportdevices
Checking devicesfile entries for the incomplete VG
adding entry to the devices file for /dev/sdm1
adding entry to the devices file for /dev/sde1

Checking devicesfile entries for the complete VG
IDTYPE=sys_wwid IDNAME=naa.6d09466083d8e100233c180321c0e570 DEVNAME=/dev/sdf1 PVID=8mlCNYBvu9n779zxJYO5RIlLNUek8crU PART=1
IDTYPE=sys_wwid IDNAME=naa.6d09466083d8e100233c1809221dc983 DEVNAME=/dev/sdg1 PVID=VFIzHlCjpbHSnMJzXdf6Bk0WDQvAaOPc PART=1

removing vg incomplete from hayes-03
  Volume group "incomplete" successfully removed
adding entry to the devices file for /dev/sdm1
removing pv /dev/sdm1 on hayes-03
  Labels on physical volume "/dev/sdm1" successfully wiped.
removing entry from the devices file for /dev/sdm1
adding entry to the devices file for /dev/sde1
removing pv /dev/sde1 on hayes-03
  Labels on physical volume "/dev/sde1" successfully wiped.
removing entry from the devices file for /dev/sde1
adding entry to the devices file for /dev/sdf1
removing pv /dev/sdf1 on hayes-03
  Labels on physical volume "/dev/sdf1" successfully wiped.
removing entry from the devices file for /dev/sdf1
adding entry to the devices file for /dev/sdg1
removing pv /dev/sdg1 on hayes-03
  Labels on physical volume "/dev/sdg1" successfully wiped.
removing entry from the devices file for /dev/sdg1
adding entry to the devices file for /dev/sdl1
removing pv /dev/sdl1 on hayes-03
  Labels on physical volume "/dev/sdl1" successfully wiped.
removing entry from the devices file for /dev/sdl1
adding entry to the devices file for /dev/sda
removing pv /dev/sda on hayes-03
  Labels on physical volume "/dev/sda" successfully wiped.
removing entry from the devices file for /dev/sda

Comment 10 Corey Marthaler 2023-01-18 17:49:33 UTC
Marking VERIFIED with the latest rpms as well, based on discussion over NOTABUG 2161759#c1

kernel-5.14.0-231.el9    BUILT: Mon Jan  9 08:32:41 PM CET 2023
lvm2-2.03.17-4.el9    BUILT: Tue Jan 10 06:40:12 PM CET 2023
lvm2-libs-2.03.17-4.el9    BUILT: Tue Jan 10 06:40:12 PM CET 2023


SCENARIO - vgimportdevices_from_incomplete_vg_w_removed_entry_and_offline_device:  Test importing from incomplete VG with an offline and removed entry device (bug 2124970|2139512) 
Ensuring lvm2-lvmdbusd is started to verify bug 2085078

adding entry to the devices file for /dev/sda
creating PV on virt-558.cluster-qe.lab.eng.brq.redhat.com using device /dev/sda
pvcreate --yes -ff   /dev/sda
WARNING: Heartbeat did not respond at start of command.  Check btimed service on remote host
  Physical volume "/dev/sda" successfully created.
adding entry to the devices file for /dev/sdb
creating PV on virt-558.cluster-qe.lab.eng.brq.redhat.com using device /dev/sdb
pvcreate --yes -ff   /dev/sdb
  Physical volume "/dev/sdb" successfully created.
adding entry to the devices file for /dev/sdc
creating PV on virt-558.cluster-qe.lab.eng.brq.redhat.com using device /dev/sdc
pvcreate --yes -ff   /dev/sdc
  Physical volume "/dev/sdc" successfully created.
adding entry to the devices file for /dev/sdd
creating PV on virt-558.cluster-qe.lab.eng.brq.redhat.com using device /dev/sdd
pvcreate --yes -ff   /dev/sdd
  Physical volume "/dev/sdd" successfully created.
adding entry to the devices file for /dev/sde
creating PV on virt-558.cluster-qe.lab.eng.brq.redhat.com using device /dev/sde
pvcreate --yes -ff   /dev/sde
WARNING: Heartbeat did not respond at start of command.  Check btimed service on remote host
  Physical volume "/dev/sde" successfully created.
creating VG on virt-558.cluster-qe.lab.eng.brq.redhat.com using PV(s) /dev/sda /dev/sdb
vgcreate    incomplete /dev/sda /dev/sdb
  Volume group "incomplete" successfully created
creating VG on virt-558.cluster-qe.lab.eng.brq.redhat.com using PV(s) /dev/sdc /dev/sdd
vgcreate    complete /dev/sdc /dev/sdd
  Volume group "complete" successfully created

* Removing the devicesfile completely *
pvscan
  PV /dev/sdc    VG complete        lvm2 [<80.00 GiB / <80.00 GiB free]
  PV /dev/sdd    VG complete        lvm2 [<80.00 GiB / <80.00 GiB free]
  PV /dev/vda2   VG rhel_virt-558   lvm2 [<7.00 GiB / 0    free]
  PV /dev/sda    VG incomplete      lvm2 [<80.00 GiB / <80.00 GiB free]
  PV /dev/sdb    VG incomplete      lvm2 [<80.00 GiB / <80.00 GiB free]
  PV /dev/sde                       lvm2 [80.00 GiB]
  Total: 6 [406.98 GiB] / in use: 5 [326.98 GiB] / in no VG: 1 [80.00 GiB]
Disabling device sda on virt-558.cluster-qe.lab.eng.brq.redhat.com
'echo offline > /sys/block/sda/device/state'
pvscan
  PV /dev/sdc    VG complete        lvm2 [<80.00 GiB / <80.00 GiB free]
  PV /dev/sdd    VG complete        lvm2 [<80.00 GiB / <80.00 GiB free]
  WARNING: Couldn't find device with uuid y3Dtbm-cklI-2uDG-sBQ2-tGYO-UzRV-Fqzgh2.
  WARNING: VG incomplete is missing PV y3Dtbm-cklI-2uDG-sBQ2-tGYO-UzRV-Fqzgh2 (last written to /dev/sda).
  PV [unknown]   VG incomplete      lvm2 [<80.00 GiB / <80.00 GiB free]
  PV /dev/sdb    VG incomplete      lvm2 [<80.00 GiB / <80.00 GiB free]
  PV /dev/vda2   VG rhel_virt-558   lvm2 [<7.00 GiB / 0    free]
  PV /dev/sde                       lvm2 [80.00 GiB]
  Total: 6 [406.98 GiB] / in use: 5 [326.98 GiB] / in no VG: 1 [80.00 GiB]

* Only devices in the complete VG are to be restored *
vgimportdevices -a
  Not importing devices for VG incomplete with missing PV y3DtbmcklI2uDGsBQ2tGYOUzRVFqzgh2.
  Added 3 devices to devices file.

removing vg complete from virt-558.cluster-qe.lab.eng.brq.redhat.com
  Volume group "complete" successfully removed

* No devices will be restored when attempted on *just* the remaining incomplete VG *
vgimportdevices incomplete
  Not importing devices for VG incomplete with missing PV y3DtbmcklI2uDGsBQ2tGYOUzRVFqzgh2.

* No devices should be restored when attempted on *all* with just the incomplete VG remaining (except for a potential root device) *
vgimportdevices -a
  Not importing devices for VG incomplete with missing PV y3DtbmcklI2uDGsBQ2tGYOUzRVFqzgh2.
  Added 1 devices to devices file.

  WARNING: Couldn't find device with uuid y3Dtbm-cklI-2uDG-sBQ2-tGYO-UzRV-Fqzgh2.
  WARNING: VG incomplete is missing PV y3Dtbm-cklI-2uDG-sBQ2-tGYO-UzRV-Fqzgh2 (last written to /dev/sda).
  WARNING: Couldn't find device with uuid y3Dtbm-cklI-2uDG-sBQ2-tGYO-UzRV-Fqzgh2.

Enabling device sda on virt-558.cluster-qe.lab.eng.brq.redhat.com
'echo running > /sys/block/sda/device/state'
Verify that all removed devices file entries can be recreated using vgimportdevices
Checking devicesfile entries for the incomplete VG
adding entry to the devices file for /dev/sda
adding entry to the devices file for /dev/sdb

Checking devicesfile entries for the complete VG
IDTYPE=sys_wwid IDNAME=naa.6001405424137e80a274455bb40752b1 DEVNAME=/dev/sdc PVID=ri2oTAAyf1Vj3Vrf8r0CHjCMe36PFe9R
IDTYPE=sys_wwid IDNAME=naa.60014051add10da0d954b279be666e79 DEVNAME=/dev/sdd PVID=ZarybcqADJwaxJQDeoiZbOIJeNd1sj2q

removing vg incomplete from virt-558.cluster-qe.lab.eng.brq.redhat.com
  Volume group "incomplete" successfully removed
adding entry to the devices file for /dev/sda
removing pv /dev/sda on virt-558.cluster-qe.lab.eng.brq.redhat.com
  Labels on physical volume "/dev/sda" successfully wiped.
removing entry from the devices file for /dev/sda
adding entry to the devices file for /dev/sdb
removing pv /dev/sdb on virt-558.cluster-qe.lab.eng.brq.redhat.com
  Labels on physical volume "/dev/sdb" successfully wiped.
removing entry from the devices file for /dev/sdb
adding entry to the devices file for /dev/sdc
removing pv /dev/sdc on virt-558.cluster-qe.lab.eng.brq.redhat.com
  Labels on physical volume "/dev/sdc" successfully wiped.
removing entry from the devices file for /dev/sdc
adding entry to the devices file for /dev/sdd
removing pv /dev/sdd on virt-558.cluster-qe.lab.eng.brq.redhat.com
  Labels on physical volume "/dev/sdd" successfully wiped.
removing entry from the devices file for /dev/sdd
adding entry to the devices file for /dev/sde
removing pv /dev/sde on virt-558.cluster-qe.lab.eng.brq.redhat.com
  Labels on physical volume "/dev/sde" successfully wiped.
removing entry from the devices file for /dev/sde

Searching for MThreadRunner: exception in syslog

Comment 12 errata-xmlrpc 2023-05-09 08:23:45 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