Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1358525 - need a "device not found" error when attempting vgcreate w/ invalid device
Summary: need a "device not found" error when attempting vgcreate w/ invalid device
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: lvm2
Version: 7.3
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Bryn M. Reeves
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-20 22:13 UTC by Corey Marthaler
Modified: 2017-08-01 21:47 UTC (History)
8 users (show)

Fixed In Version: lvm2-2.02.171-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-01 21:47:18 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:2222 normal SHIPPED_LIVE lvm2 bug fix and enhancement update 2017-08-01 18:42:41 UTC

Description Corey Marthaler 2016-07-20 22:13:51 UTC
Description of problem:

[root@host-083 ~]# pvcreate
  Please enter a physical volume path.

[root@host-083 ~]# pvcreate foo
  Device foo not found (or ignored by filtering).

[root@host-083 ~]# vgcreate
  Please provide volume group name and physical volumes
  Run `vgcreate --help' for more information.

[root@host-083 ~]# vgcreate foo
  Command failed with status code 5.

[root@host-083 ~]# vgcreate /dev/foo
  Command failed with status code 5.


Version-Release number of selected component (if applicable):
3.10.0-468.el7.x86_64

lvm2-2.02.161-2.el7    BUILT: Wed Jul 20 07:48:14 CDT 2016
lvm2-libs-2.02.161-2.el7    BUILT: Wed Jul 20 07:48:14 CDT 2016
lvm2-cluster-2.02.161-2.el7    BUILT: Wed Jul 20 07:48:14 CDT 2016
device-mapper-1.02.131-2.el7    BUILT: Wed Jul 20 07:48:14 CDT 2016
device-mapper-libs-1.02.131-2.el7    BUILT: Wed Jul 20 07:48:14 CDT 2016
device-mapper-event-1.02.131-2.el7    BUILT: Wed Jul 20 07:48:14 CDT 2016
device-mapper-event-libs-1.02.131-2.el7    BUILT: Wed Jul 20 07:48:14 CDT 2016
device-mapper-persistent-data-0.6.2-1.el7    BUILT: Mon Jul 11 04:32:34 CDT 2016
cmirror-2.02.161-2.el7    BUILT: Wed Jul 20 07:48:14 CDT 2016
sanlock-3.4.0-1.el7    BUILT: Fri Jun 10 11:41:03 CDT 2016
sanlock-lib-3.4.0-1.el7    BUILT: Fri Jun 10 11:41:03 CDT 2016
lvm2-lockd-2.02.161-2.el7    BUILT: Wed Jul 20 07:48:14 CDT 2016

Comment 2 Bryn M. Reeves 2016-07-21 15:47:21 UTC
With a /dev/... argument that is a valid device the message changes to:

# vgcreate /dev/sda
  /dev/sda: already exists in filesystem
  Run `vgcreate --help' for more information.

(i.e the single argument is being taken for a VG name).

Comment 3 Bryn M. Reeves 2016-07-21 16:07:37 UTC
It's trivial to check this directly in vgcreate.c, changing the above cases to:

# lvm vgcreate 
  Please provide volume group name and physical volumes
  Run `vgcreate --help' for more information.

# lvm vgcreate qux
  Please provide physical volumes for new volume group qux
  Run `vgcreate --help' for more information.

# lvm vgcreate /dev/sda
  Volume group name expected before physical volume arguments
  Run `vgcreate --help' for more information.

Before I commit this though I'll take a look to see if it doesn't make sense to push this down into the existing validation routines (from vgcreate()).

Comment 4 Zdenek Kabelac 2016-07-21 18:50:12 UTC
Upstream commit is actually causing regression:

https://www.redhat.com/archives/lvm-devel/2016-July/msg00200.html

# vgcreate /dev/vg /dev/sda1 /dev/sdb1  

is valid syntax.

User is free to use or not use "/dev" prefix (lvm.conf defined) with all lvm2 commands. Obviously  'vgname'  may 'collide' with some other existing device name and such vgname can't be then used (aka  'vgcreate sda'  is bad idea).

But this is well known limitation - even thought some users would like to see this limit to be dropped and lvm2 would not 'create' any /dev/vgname/lvname links and just  /dev/mapper/vgname-lvname....

There is an 'interesting' problem how to deal with 'globally' supported 'envvar'   LVM_VG_NAME  (man lvm).

Comment 5 Alasdair Kergon 2016-09-28 17:55:22 UTC
Regression.  Old code gave:

  Please enter a physical volume path.

Comment 8 Bryn M. Reeves 2017-04-13 16:56:32 UTC
With the new command definitions all three cases are caught by the generic required argument/option checking message:

# vgcreate
  Incorrect syntax. Run 'vgcreate --help' for more information.
# vgcreate foo
  Incorrect syntax. Run 'vgcreate --help' for more information.
# vgcreate /dev/foo
  Incorrect syntax. Run 'vgcreate --help' for more information.

Comment 9 Bryn M. Reeves 2017-04-28 15:13:23 UTC
Spoke with Dave and although this is a change of behaviour from previous versions, the current behaviour is not incorrect: it correctly points the user to the too --help output which would correct the command misuse.

To address this and cause it to behave as previously, the simplest way that I could see would involve adding dummy command definitions simply to allow the dummy command to output a more exact error message - this seems a fair amount of hack just to slavishly match the original messages.

In the case of vgcreate (unlike many of the new command definitions) there is only one valid syntax accepted (modulo the different ways of expressing the volume group name): Dave suggests that this could be used with the existing "nearest similar syntax" logic to output a more exact message in these single syntax command cases.

This gives us a clear route to improve this in the future without resorting to short term kludges.

Comment 10 Bryn M. Reeves 2017-04-28 15:18:14 UTC
I thought I'd seen another commit for this via mail, but didn't spot it when I went to look a moment ago:

commit 86b9c23dbe4a5033eea6667c0274655e7c0c8e68
Author: David Teigland <teigland@redhat.com>
Date:   Thu Apr 27 14:21:01 2017 -0500

    commands: improve syntax suggestion when no command is found
    
    The logic for suggesting the nearest valid command syntax
    was missing the simplest case.  If a command has only one
    valid syntax, that is the one we should suggest.  (We were
    suggesting nothing in this case.)

With this commit the three prior examples now output the expected usage:

# lvm vgcreate
  No command with matching syntax recognised.  Run 'vgcreate --help' for more information.
  Correct command syntax is:
  vgcreate VG_new PV ...

# lvm vgcreate foo
  No command with matching syntax recognised.  Run 'vgcreate --help' for more information.
  Correct command syntax is:
  vgcreate VG_new PV ...

# lvm vgcreate /dev/foo
  No command with matching syntax recognised.  Run 'vgcreate --help' for more information.
  Correct command syntax is:
  vgcreate VG_new PV ...

Comment 12 Corey Marthaler 2017-05-03 16:14:40 UTC
Marking verified based on the new behavior expected outlined in comment #10.

3.10.0-660.el7.x86_64

lvm2-2.02.171-1.el7    BUILT: Wed May  3 07:05:13 CDT 2017
lvm2-libs-2.02.171-1.el7    BUILT: Wed May  3 07:05:13 CDT 2017
lvm2-cluster-2.02.171-1.el7    BUILT: Wed May  3 07:05:13 CDT 2017
device-mapper-1.02.140-1.el7    BUILT: Wed May  3 07:05:13 CDT 2017
device-mapper-libs-1.02.140-1.el7    BUILT: Wed May  3 07:05:13 CDT 2017
device-mapper-event-1.02.140-1.el7    BUILT: Wed May  3 07:05:13 CDT 2017
device-mapper-event-libs-1.02.140-1.el7    BUILT: Wed May  3 07:05:13 CDT 2017
device-mapper-persistent-data-0.7.0-0.1.rc6.el7    BUILT: Mon Mar 27 10:15:46 CDT 2017



[root@host-126 ~]# pvcreate
  No command with matching syntax recognised.  Run 'pvcreate --help' for more information.
  Correct command syntax is:
  pvcreate PV ...

[root@host-126 ~]# pvcreate foo
  Device foo not found (or ignored by filtering).
[root@host-126 ~]# vgcreate
  No command with matching syntax recognised.  Run 'vgcreate --help' for more information.
  Correct command syntax is:
  vgcreate VG_new PV ...

[root@host-126 ~]# vgcreate foo
  No command with matching syntax recognised.  Run 'vgcreate --help' for more information.
  Correct command syntax is:
  vgcreate VG_new PV ...

[root@host-126 ~]# vgcreate /dev/foo
  No command with matching syntax recognised.  Run 'vgcreate --help' for more information.
  Correct command syntax is:
  vgcreate VG_new PV ...

Comment 13 errata-xmlrpc 2017-08-01 21:47:18 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, 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-2017:2222


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