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

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