Bug 179473 - removal of invalid PV should fail
Summary: removal of invalid PV should fail
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: lvm2
Version: 4.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Alasdair Kergon
QA Contact:
URL:
Whiteboard:
: 180763 (view as bug list)
Depends On:
Blocks: 181409 185136
TreeView+ depends on / blocked
 
Reported: 2006-01-31 17:32 UTC by Corey Marthaler
Modified: 2018-10-19 18:59 UTC (History)
3 users (show)

Fixed In Version: RHBA-2006-0504
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-08-10 21:45:41 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2006:0504 0 normal SHIPPED_LIVE lvm2 bug fix and enhancement update 2006-08-10 04:00:00 UTC

Description Corey Marthaler 2006-01-31 17:32:09 UTC
Description of problem:
[root@link-08 ~]# pvscan
  No matching physical volumes found
[root@link-08 ~]# pvremove /dev/sda2
  No physical volume label read from /dev/sda2
  Labels on physical volume "/dev/sda2" successfully wiped
[root@link-08 ~]# echo $?
0

If there's no physical volume label read, then what exactly is it successfully
wipping?


Version-Release number of selected component (if applicable):
[root@link-08 ~]# pvremove --version
  LVM version:     2.02.01 (2005-11-23)
  Library version: 1.02.02 (2006-01-04)
  Driver version:  4.5.0

Comment 1 Alasdair Kergon 2006-02-01 20:04:29 UTC
It's not so much the message that's wrong, it's the fact that if there are no
labels there it would be safer to do nothing (and exit with success).

Comment 2 Alasdair Kergon 2006-02-10 21:02:57 UTC
*** Bug 180763 has been marked as a duplicate of this bug. ***

Comment 3 Alasdair Kergon 2006-02-10 21:10:24 UTC
If I run pvremove on the same disk twice in succession, I want it to exit with
success both times, but only to write something to the disk the first time.  In
line with my earlier comment, the message can be suppressed if nothing was written.

When I run pvremove I'm only interested in the *final state* after the command
ran, not any actions the command itself took.  When I run pvremove, my intention
is "make sure this disk is not recognised by LVM2 as a PV".  So I get 'success'
if that is true; 'failure' if it isn't.  I'll expand the man page to explain this.

If there's disagreement on this point and someone can justify wanting to know
from the return code whether or not any label had to be wiped then I'll set
about making it a configurable option.


Comment 4 Corey Marthaler 2006-02-10 21:32:16 UTC
I disagree, why not make that same argument in the following cases then?

[root@link-08 bin]# lvremove -f /dev/stripe_1_9746/stripe_1_97460
  Logical volume "stripe_1_97460" successfully removed
[root@link-08 bin]# echo $?
0
[root@link-08 bin]# lvremove -f /dev/stripe_1_9746/stripe_1_97460
  One or more specified logical volume(s) not found.
[root@link-08 bin]# echo $?
5

[root@link-08 bin]# vgremove stripe_1_9746
  Volume group "stripe_1_9746" successfully removed
[root@link-08 bin]# echo $?
0
[root@link-08 bin]# vgremove stripe_1_9746
  Volume group "stripe_1_9746" not found or inconsistent.
  Consider vgreduce --removemissing if metadata is inconsistent.
[root@link-08 bin]# echo $?
5

[root@link-08 tmp]# rmdir lvm
[root@link-08 tmp]# echo $?
0
[root@link-08 tmp]# rmdir lvm
rmdir: `lvm': No such file or directory
[root@link-08 tmp]# echo $?
1

[root@link-08 tmp]# rm goo
rm: remove regular empty file `goo'? y
[root@link-08 tmp]# echo $?
0
[root@link-08 tmp]# rm goo
rm: cannot lstat `goo': No such file or directory
[root@link-08 tmp]# echo $?
1



Comment 5 Alasdair Kergon 2006-02-13 14:14:45 UTC
The difference is that with the PV operations the focus of the commands is on
the final state not the process needed to reach it: ensuring that a device is or
is not recognised as usable by LVM.  Running the commands repeatedly causes no
problems and is a common thing for people to do.  If I run 'pvcreate' or
'pvremove' twice the system ends up in the state requested so the command
succeeds - if it failed the second time that would cause unnecessary annoyance.
  VG and LV operations on the other hand are concerned with manipulating
structures in namespaces - if I attempt to remove a logical volume that doesn't
exist I *do* want to be told.

If I change this, it will cause some people's scripts to fail for no good reason.

A compromise might be to use the '--force' flag to let people choose the
behaviour they prefer: to give an error without the flag, but success with it.


Comment 8 Alasdair Kergon 2006-04-05 22:18:55 UTC
Committed upstream.

Comment 9 Alasdair Kergon 2006-04-05 22:20:12 UTC
pvremove without -f now fails if there's no PV label.

Comment 14 Corey Marthaler 2006-07-06 20:13:06 UTC
fix verified.

Comment 16 Red Hat Bugzilla 2006-08-10 21:45:42 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2006-0504.html



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