Blame SOURCES/LVM-activate-2-parameters-access-mode-fixes.patch

b94b9d
From 792077bf2994e2e582ccfb0768f3186517de9025 Mon Sep 17 00:00:00 2001
b94b9d
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
b94b9d
Date: Fri, 21 Sep 2018 12:00:07 +0200
b94b9d
Subject: [PATCH] LVM-activate: fixes
b94b9d
b94b9d
- read parameters for start/stop/monitor-actions
b94b9d
- fail during monitor-action when run with incorrect access_mode
b94b9d
---
b94b9d
 heartbeat/LVM-activate | 44 ++++++++++++++++++++++++++----------------
b94b9d
 1 file changed, 27 insertions(+), 17 deletions(-)
b94b9d
b94b9d
diff --git a/heartbeat/LVM-activate b/heartbeat/LVM-activate
b94b9d
index 55e36a2d2..f46932c1c 100755
b94b9d
--- a/heartbeat/LVM-activate
b94b9d
+++ b/heartbeat/LVM-activate
b94b9d
@@ -56,6 +56,7 @@ LV=${OCF_RESKEY_lvname}
b94b9d
 # 3: vg has system_id (new)
b94b9d
 # 4: vg has tagging (old)
b94b9d
 VG_access_mode=${OCF_RESKEY_vg_access_mode}
b94b9d
+VG_access_mode_num=0
b94b9d
 
b94b9d
 # Activate LV(s) with "shared" lock for cluster fs
b94b9d
 # or "exclusive" lock for local fs
b94b9d
@@ -176,7 +177,9 @@ END
b94b9d
 # 2: vg is clustered - clvmd (old)
b94b9d
 # 3: vg has system_id (new)
b94b9d
 # 4: vg has tagging (old)
b94b9d
-get_VG_access_mode() {
b94b9d
+
b94b9d
+get_VG_access_mode_num()
b94b9d
+{
b94b9d
 	local access_mode
b94b9d
 	local vg_locktype
b94b9d
 	local vg_clustered
b94b9d
@@ -415,11 +418,8 @@ tagging_check()
b94b9d
         return $OCF_SUCCESS
b94b9d
 }
b94b9d
 
b94b9d
-lvm_validate() {
b94b9d
-	local lv_count
b94b9d
-	local mode
b94b9d
-
b94b9d
-	# Parameters checking
b94b9d
+read_parameters()
b94b9d
+{
b94b9d
 	if [ -z "$VG" ]
b94b9d
 	then
b94b9d
 		ocf_exit_reason "You must identify the volume group name!"
b94b9d
@@ -435,22 +435,30 @@ lvm_validate() {
b94b9d
 	# Convert VG_access_mode from string to index
b94b9d
 	case ${VG_access_mode} in
b94b9d
 	lvmlockd)
b94b9d
-		VG_access_mode=1
b94b9d
+		VG_access_mode_num=1
b94b9d
 		;;
b94b9d
 	clvmd)
b94b9d
-		VG_access_mode=2
b94b9d
+		VG_access_mode_num=2
b94b9d
 		;;
b94b9d
 	system_id)
b94b9d
-		VG_access_mode=3
b94b9d
+		VG_access_mode_num=3
b94b9d
 		;;
b94b9d
 	tagging)
b94b9d
-		VG_access_mode=4
b94b9d
+		VG_access_mode_num=4
b94b9d
 		;;
b94b9d
 	*)
b94b9d
+		# dont exit with error-code here or nodes will get fenced on
b94b9d
+		# e.g. "pcs resource create"
b94b9d
 		ocf_exit_reason "You specified an invalid value for vg_access_mode: $VG_access_mode"
b94b9d
-		exit $OCF_ERR_CONFIGURED
b94b9d
 		;;
b94b9d
 	esac
b94b9d
+}
b94b9d
+
b94b9d
+lvm_validate() {
b94b9d
+	local lv_count
b94b9d
+	local mode
b94b9d
+
b94b9d
+	read_parameters
b94b9d
 
b94b9d
 	check_binary pgrep
b94b9d
 	# Every LVM command is just symlink to lvm binary
b94b9d
@@ -471,9 +479,9 @@ lvm_validate() {
b94b9d
 	# Get the access mode from VG metadata and check if it matches the input
b94b9d
 	# value. Skip to check "tagging" mode because there's no reliable way to
b94b9d
 	# automatically check if "tagging" mode is being used.
b94b9d
-	get_VG_access_mode
b94b9d
+	get_VG_access_mode_num
b94b9d
 	mode=$?
b94b9d
-	if [ $VG_access_mode -ne 4 ] && [ $mode -ne $VG_access_mode ]; then
b94b9d
+	if [ $VG_access_mode_num -ne 4 ] && [ $mode -ne $VG_access_mode_num ]; then
b94b9d
 		ocf_exit_reason "The specified vg_access_mode doesn't match the lock_type on VG metadata!"
b94b9d
 		exit $OCF_ERR_ARGS
b94b9d
 	fi
b94b9d
@@ -495,8 +503,8 @@ lvm_validate() {
b94b9d
 		fi
b94b9d
 	fi
b94b9d
 
b94b9d
-	# VG_access_mode specific checking goes here
b94b9d
-	case ${VG_access_mode} in
b94b9d
+	# VG_access_mode_num specific checking goes here
b94b9d
+	case ${VG_access_mode_num} in
b94b9d
 	1)
b94b9d
 		lvmlockd_check
b94b9d
 		;;
b94b9d
@@ -731,7 +739,7 @@ lvm_start() {
b94b9d
 	[ -z ${LV} ] && vol=${VG} || vol=${VG}/${LV}
b94b9d
 	ocf_log info "Activating ${vol}"
b94b9d
 
b94b9d
-	case ${VG_access_mode} in
b94b9d
+	case ${VG_access_mode_num} in
b94b9d
 	1)
b94b9d
 		lvmlockd_activate
b94b9d
 		;;
b94b9d
@@ -773,7 +781,7 @@ lvm_stop() {
b94b9d
 
b94b9d
 	ocf_log info "Deactivating ${vol}"
b94b9d
 
b94b9d
-	case ${VG_access_mode} in
b94b9d
+	case ${VG_access_mode_num} in
b94b9d
 	1)
b94b9d
 		lvmlockd_deactivate
b94b9d
 		;;
b94b9d
@@ -811,9 +819,11 @@ start)
b94b9d
 	lvm_start
b94b9d
 	;;
b94b9d
 stop)
b94b9d
+	read_parameters
b94b9d
 	lvm_stop
b94b9d
 	;;
b94b9d
 monitor)
b94b9d
+	lvm_validate
b94b9d
 	lvm_status
b94b9d
 	;;
b94b9d
 validate-all)