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

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