Bug 230146

Summary: RFE: allow the cmdline suppression of locking errors for scriptability
Product: Red Hat Enterprise Linux 5 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: LVM and device-mapper development team <lvm-team>
Status: CLOSED NEXTRELEASE QA Contact: Corey Marthaler <cmarthal>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.5CC: agk, dwysocha, heinzm, jbrassow, joe.thornber, lmiksik, prajnoha, prockai, zkabelac
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-05 15:04:56 UTC Type: ---
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 2007-02-26 21:01:07 UTC
Description of problem:
This was allowed in rhel4u4, so maybe this is a regression of sorts. When one
wants to do cmdline scripting, they don't want to deal with the locking errors,
and if they are so important, then make the cmds error code non zero.

RHEL4u4 - 
[root@link-02 ~]# lvs --ignorelockingfailure
  connect() failed on local socket: Connection refused
  LV        VG       Attr   LSize   Origin Snap%  Move Log Copy%
  LINK_1280 LINK_128 -wi--- 949.59G
[root@link-02 ~]# echo $?
0
[root@link-02 ~]# lvs
  connect() failed on local socket: Connection refused
  Locking type 2 initialisation failed.
[root@link-02 ~]# echo $?
5


RHEL4u5 -
[root@taft-02 ~]# lvs
  connect() failed on local socket: Connection refused
  WARNING: Falling back to local file-based locking.
  Volume Groups with the clustered attribute will be inaccessible.
  LV       VG         Attr   LSize  Origin Snap%  Move Log Copy%
  LogVol00 VolGroup00 -wi-ao 66.16G
  LogVol01 VolGroup00 -wi-ao  1.94G
  foo      corey      -wi--- 10.00G
  lvol0    corey      -wi--- 10.00G
[root@taft-02 ~]# echo $?
0
[root@taft-02 ~]# lvs --ignorelockingfailure
  connect() failed on local socket: Connection refused
  WARNING: Falling back to local file-based locking.
  Volume Groups with the clustered attribute will be inaccessible.
  LV       VG         Attr   LSize  Origin Snap%  Move Log Copy%
  LogVol00 VolGroup00 -wi-ao 66.16G
  LogVol01 VolGroup00 -wi-ao  1.94G
  foo      corey      -wi--- 10.00G
  lvol0    corey      -wi--- 10.00G
[root@taft-02 ~]# echo $?
0



Version-Release number of selected component (if applicable):
2.6.9-48.ELsmp
lvm2-2.02.21-3.el4

Comment 1 Milan Broz 2008-04-08 10:29:52 UTC
I think this is fixed (lvm2-2.02.27-2), messages are printed to stderr so can be
 sent to /dev/null :) - is it what you want for scripting?

[root@bar-01 lvm2]# lvs ; echo $?
  connect() failed on local socket: Connection refused
  WARNING: Falling back to local file-based locking.
  Volume Groups with the clustered attribute will be inaccessible.
  Skipping clustered volume group vg_bar
  LV      VG       Attr   LSize  Origin Snap%  Move Log Copy%
  rootvol myvg     -wi-a- 33.59G
  lv_test vg_local -wi-a-  1.00G
  root    vg_rhel4 -wi-ao 33.56G
5
[root@bar-01 lvm2]# lvs --ignorelockingfailure 2>/dev/null; echo $?
  LV      VG       Attr   LSize  Origin Snap%  Move Log Copy%
  rootvol myvg     -wi-a- 33.59G
  lv_test vg_local -wi-a-  1.00G
  root    vg_rhel4 -wi-ao 33.56G
5
[root@bar-01 lvm2]# clvmd
[root@bar-01 lvm2]# lvs --ignorelockingfailure ; echo $?
  LV      VG       Attr   LSize  Origin Snap%  Move Log Copy%
  rootvol myvg     -wi-a- 33.59G
  lv_test vg_bar   -wi-a-  1.00G
  lv_test vg_local -wi-a-  1.00G
  root    vg_rhel4 -wi-ao 33.56G
0


Comment 2 Corey Marthaler 2008-06-05 14:55:30 UTC
That's not really what I had in mind. I'm curious why after rhel4u5, the
'--ignorelockingfailure' seems to no longer do anything. By your logic, if
you're going to use /dev/null anyways, then why use the '--ignorelockingfailure'
at all?

[root@taft-01 sbin]# lvs --ignorelockingfailure 2>/dev/null; echo $?
  LV       VG         Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  LogVol00 VolGroup00 -wi-ao 58.34G
  LogVol01 VolGroup00 -wi-ao  9.75G
5
[root@taft-01 sbin]# lvs 2>/dev/null; echo $?
  LV       VG         Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  LogVol00 VolGroup00 -wi-ao 58.34G
  LogVol01 VolGroup00 -wi-ao  9.75G
5

Why doesn't the '--ignorelockingfailure' suppress those errors by itself like it
used to in comment #0.

RHEL4u4 - 
[root@link-02 ~]# lvs --ignorelockingfailure
  connect() failed on local socket: Connection refused
  LV        VG       Attr   LSize   Origin Snap%  Move Log Copy%
  LINK_1280 LINK_128 -wi--- 949.59G
[root@link-02 ~]# echo $?
0

Comment 3 Milan Broz 2010-05-17 12:17:47 UTC
There some new switches, but still probably something missing.
Anyway, not RHEL4 material, moving to RHEL5 for now...

Comment 4 Zdenek Kabelac 2013-05-14 20:35:30 UTC
Do we still have this problem - or can we fix this as next release (RHEL5) ?

Comment 5 Corey Marthaler 2013-05-15 20:12:33 UTC
Looks like "--ignorelockingfailure" still doesn't do anything. The cluster volume w/o clvmd running still isn't visible.

## RHEL6.4
[root@taft-01 ~]# lvs --ignorelockingfailure
  connect() failed on local socket: No such file or directory
  Internal cluster locking initialisation failed.
  WARNING: Falling back to local file-based locking.
  Volume Groups with the clustered attribute will be inaccessible.
  Skipping clustered volume group cluster
  Skipping volume group cluster
  LV      VG        Attr      LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_home vg_taft01 -wi-ao---  9.94g
  lv_root vg_taft01 -wi-ao--- 50.00g
  lv_swap vg_taft01 -wi-ao---  7.81g
[root@taft-01 ~]# echo $?
5
[root@taft-01 ~]# lvs
  connect() failed on local socket: No such file or directory
  Internal cluster locking initialisation failed.
  WARNING: Falling back to local file-based locking.
  Volume Groups with the clustered attribute will be inaccessible.
  Skipping clustered volume group cluster
  Skipping volume group cluster
  LV      VG        Attr      LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_home vg_taft01 -wi-ao---  9.94g
  lv_root vg_taft01 -wi-ao--- 50.00g
  lv_swap vg_taft01 -wi-ao---  7.81g
[root@taft-01 ~]# echo $?
5

Comment 7 Peter Rajnoha 2014-02-05 15:04:56 UTC
(In reply to Corey Marthaler from comment #5)
> Looks like "--ignorelockingfailure" still doesn't do anything. The cluster
> volume w/o clvmd running still isn't visible.
> 
> ## RHEL6.4
> [root@taft-01 ~]# lvs --ignorelockingfailure
>   connect() failed on local socket: No such file or directory
>   Internal cluster locking initialisation failed.
>   WARNING: Falling back to local file-based locking.
>   Volume Groups with the clustered attribute will be inaccessible.
>   Skipping clustered volume group cluster
>   Skipping volume group cluster
>   LV      VG        Attr      LSize  Pool Origin Data%  Move Log Cpy%Sync
> Convert 
>   lv_home vg_taft01 -wi-ao---  9.94g
>   lv_root vg_taft01 -wi-ao--- 50.00g
>   lv_swap vg_taft01 -wi-ao---  7.81g
> [root@taft-01 ~]# echo $?
> 5

This does not end with return code 5 because cluster locking failed, but because we were unable to list all logical volumes.

With recent code (lvm2 v2.02.103 and higher), we have a new option "--ignoreskippedcluster" that does what's needed here - to skip clustered VGs without disrupting the final lvm command return code.

The warning messages about failed locking initialisation will be always issued *unless* either of these are used:

  - the "--sysinit" option is used (this is aimed to be used in scripts during boot so the boot scripts don't need to modify the lvm.conf heavily just to pass the boot where the cluster is not yet set up)

  - the LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1 environment variable - one can use this if it's really really needed to suppress the messages for whatever reason (but normally we don't recommend this as the warning messages are useful to inform user that something is not going the way as intended)

So to sum it up, 3 things:
  - the --sysinit option (which is just a shortcut for setting certain other options, see the man page for more info, e.g. vgchange and lvchange one)
  - the LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1 environment variable
  - the --ignoreskippedcluster option (available in 6.5+)

There may be an argument that this is complex, but it's actually to be used only in specific situations that usual users normally don't get into - it suppresses things that should normally be visible for the user - like here the warning messages...

I'm closing this one with NEXTRELEASE as this is solved in 6.5, no need to backport to 5.11 unless there are high prio customer cases requesting this functionality.

Comment 8 Peter Rajnoha 2014-02-05 15:07:31 UTC
...to solve the situation in this bug report, this should be used (with lvm2 2.02.103+):

export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
<lvm_command> --ingoreskippedcluster
...