Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-cloud / recipes-support / cluster-resource-agents / resource-agents / stx / Fix-VG-activity-bug-in-heartbeat-LVM-script.patch
1 From 7c181a1afdc85456333f9cbf9c5827ceb0554a91 Mon Sep 17 00:00:00 2001
2 From: Chris Friesen <chris.friesen@windriver.com>
3 Date: Fri, 24 Aug 2018 03:51:37 +0800
4 Subject: [PATCH] Fix VG activity bug in heartbeat/LVM script
5
6 There is currently an issue in the lvm2 package where if you create an LVM thin
7 pool, then create a thin volume in the pool, then the udev rule doesn't think
8 there should be a /dev// symlink for the thin pool, but "vgmknodes" and
9 "vgscan --mknodes" both think that there should be such a symlink. This is a
10 bug, but it's in the field in CentOS 7 at least and likely elsewhere.
11
12 The end result of this is that on such a system running either "vgscan
13 --mknodes" or "vgmknodes" and then running "vgchange -an " will
14 leave the /dev/ directory with a dangling symlink in it.
15
16 This breaks the LVM_status() function in this OCF script, since the
17 /dev/ directory exists and is not empty even though the volume
18 group is not active.
19
20 This commit changes the code to directly query lvm about the volume group
21 activity rather than relying on side effects.
22
23 Signed-off-by: zhipengl <zhipengs.liu@intel.com>
24
25 ---
26  heartbeat/LVM | 15 ++++++---------
27  1 file changed, 6 insertions(+), 9 deletions(-)
28
29 diff --git a/heartbeat/LVM b/heartbeat/LVM
30 index 893ece8..1efb207 100755
31 --- a/heartbeat/LVM
32 +++ b/heartbeat/LVM
33 @@ -191,18 +191,15 @@ LVM_status() {
34                 fi
35         fi
36         
37 -       if [ -d /dev/$1 ]; then
38 -               test "`cd /dev/$1 && ls`" != ""
39 -               rc=$?
40 -               if [ $rc -ne 0 ]; then
41 -                       ocf_exit_reason "VG $1 with no logical volumes is not supported by this RA!"
42 -               fi
43 -       fi
44 -
45 -       if [ $rc -ne 0 ]; then
46 +       # Ask lvm whether the volume group is active.  This maps to
47 +       # the question "Are there any logical volumes that are active in
48 +       # the specified volume group?".
49 +       lvs --noheadings -o selected  -S lv_active=active,vg_name=${1}|grep -q 1
50 +       if [ $? -ne 0 ]; then
51                 ocf_log $loglevel "LVM Volume $1 is not available (stopped)"
52                 rc=$OCF_NOT_RUNNING
53         else
54 +               rc=0
55                 lvm_status
56                 rc=$?
57         fi
58 -- 
59 2.7.4
60