Blame SOURCES/bz1808468-2-remove-locking_type.patch

b4b3ce
From a007883ff1537cbcb79765d174694b54b0da7acc Mon Sep 17 00:00:00 2001
b4b3ce
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
b4b3ce
Date: Thu, 27 Feb 2020 11:51:31 +0100
b4b3ce
Subject: [PATCH] lvmlockd: remove locking_type parameter from lvm.conf for LVM
b4b3ce
 > v2.03
b4b3ce
b4b3ce
---
b4b3ce
 heartbeat/lvmlockd | 24 ++++++++++++++++++------
b4b3ce
 1 file changed, 18 insertions(+), 6 deletions(-)
b4b3ce
b4b3ce
diff --git a/heartbeat/lvmlockd b/heartbeat/lvmlockd
b4b3ce
index e80c7647e..c0c45f879 100755
b4b3ce
--- a/heartbeat/lvmlockd
b4b3ce
+++ b/heartbeat/lvmlockd
b4b3ce
@@ -190,19 +190,31 @@ setup_lvm_config()
b4b3ce
 	# To use lvmlockd, ensure configure lvm.conf:
b4b3ce
 	# locking_type = 1
b4b3ce
 	# use_lvmlockd = 1
b4b3ce
-	out=$(lvmconfig 'global/use_lvmlockd')
b4b3ce
+	out=$(lvmconfig 'global/use_lvmlockd' 2> /dev/null)
b4b3ce
 	use_lvmlockd=$(echo "$out" | cut -d'=' -f2)
b4b3ce
 
b4b3ce
-	out=$(lvmconfig 'global/locking_type')
b4b3ce
+	out=$(lvmconfig 'global/locking_type' 2> /dev/null)
b4b3ce
 	lock_type=$(echo "$out" | cut -d'=' -f2)
b4b3ce
 
b4b3ce
-	if [ "$use_lvmlockd" != 1 ] ; then
b4b3ce
+	if [ -n "$use_lvmlockd" ] && [ "$use_lvmlockd" != 1 ] ; then
b4b3ce
 		ocf_log info "setting \"use_lvmlockd=1\" in /etc/lvm/lvm.conf ..."
b4b3ce
 		sed -i 's,^[[:blank:]]*use_lvmlockd[[:blank:]]*=.*,\ \ \ \ use_lvmlockd = 1,g' /etc/lvm/lvm.conf
b4b3ce
 	fi
b4b3ce
-	if [ "$lock_type" != 1 ] ; then
b4b3ce
-		ocf_log info "setting \"locking_type=1\" in /etc/lvm/lvm.conf ..."
b4b3ce
-		sed -i 's,^[[:blank:]]*locking_type[[:blank:]]*=.*,\ \ \ \ locking_type = 1,g' /etc/lvm/lvm.conf
b4b3ce
+	if [ -n "$lock_type" ] ; then
b4b3ce
+		# locking_type was removed from config in v2.03
b4b3ce
+		ocf_version_cmp "$(lvmconfig --version | awk '/LVM ver/ {sub(/\(.*/, "", $3); print $3}')" "2.03"
b4b3ce
+		case "$?" in
b4b3ce
+			1|2)
b4b3ce
+				ocf_log info "removing \"locking_type\" from /etc/lvm/lvm.conf ..."
b4b3ce
+				sed -i '/^[[:blank:]]*locking_type[[:blank:]]*=.*/d' /etc/lvm/lvm.conf
b4b3ce
+				;;
b4b3ce
+			0)
b4b3ce
+				if [ "$lock_type" != 1 ] ; then
b4b3ce
+					ocf_log info "setting \"locking_type=1\" in /etc/lvm/lvm.conf ..."
b4b3ce
+					sed -i 's,^[[:blank:]]*locking_type[[:blank:]]*=.*,\ \ \ \ locking_type = 1,g' /etc/lvm/lvm.conf
b4b3ce
+				fi
b4b3ce
+				;;
b4b3ce
+		esac
b4b3ce
 	fi
b4b3ce
 
b4b3ce
 	return $OCF_SUCCESS