Blame SOURCES/bz1905820-LVM-activate-fix-return-codes.patch

98dd5d
From 640c2b57f0f3e7256d587ddd5960341cb38b1982 Mon Sep 17 00:00:00 2001
98dd5d
From: Reid Wahl <nrwahl@protonmail.com>
98dd5d
Date: Sun, 13 Dec 2020 14:58:34 -0800
98dd5d
Subject: [PATCH] LVM-activate: Fix return codes
98dd5d
98dd5d
OCF_ERR_ARGS should be used when the configuration isn't valid for the
98dd5d
**local** node, and so the resource should not attempt to start again
98dd5d
locally until the issue is corrected.
98dd5d
98dd5d
OCF_ERR_CONFIGURED should be used when the configuration isn't valid on
98dd5d
**any** node, and so the resource should not attempt to start again
98dd5d
anywhere until the issue is corrected.
98dd5d
98dd5d
One remaining gray area: Should lvmlockd/lvmetad/clvmd improperly
98dd5d
running (or improperly not running) be an OCF_ERR_GENERIC or
98dd5d
OCF_ERR_ARGS? The fact that it's a state issue rather than a config
98dd5d
issue suggests OCF_ERR_GENERIC. The fact that it won't be fixed without
98dd5d
user intervention suggests OCF_ERR_ARGS. The approach here is to use
98dd5d
GENERIC for all of these. One can make the case that "improperly
98dd5d
running" should use ARGS, since a process must be manually stopped to
98dd5d
fix the issue, and that "improperly not running" should use GENERIC,
98dd5d
since there's a small chance the process died and will be recovered in
98dd5d
some way.
98dd5d
98dd5d
More info about return code meanings:
98dd5d
  - https://clusterlabs.org/pacemaker/doc/2.1/Pacemaker_Administration/html/agents.html#how-are-ocf-return-codes-interpreted
98dd5d
98dd5d
Resolves: RHBZ#1905820
98dd5d
98dd5d
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
98dd5d
---
98dd5d
 heartbeat/LVM-activate | 47 +++++++++++++++++++++---------------------
98dd5d
 1 file changed, 23 insertions(+), 24 deletions(-)
98dd5d
98dd5d
diff --git a/heartbeat/LVM-activate b/heartbeat/LVM-activate
98dd5d
index c86606637..e951a08e9 100755
98dd5d
--- a/heartbeat/LVM-activate
98dd5d
+++ b/heartbeat/LVM-activate
98dd5d
@@ -333,8 +333,7 @@ config_verify()
98dd5d
 	real=$(lvmconfig "$name" | cut -d'=' -f2)
98dd5d
 	if [ "$real" != "$expect" ]; then
98dd5d
 		ocf_exit_reason "config item $name: expect=$expect but real=$real"
98dd5d
-		exit $OCF_ERR_CONFIGURED
98dd5d
-
98dd5d
+		exit $OCF_ERR_ARGS
98dd5d
 	fi
98dd5d
 
98dd5d
 	return $OCF_SUCCESS
98dd5d
@@ -366,12 +365,12 @@ lvmlockd_check()
98dd5d
 		fi
98dd5d
 
98dd5d
 		ocf_exit_reason "lvmlockd daemon is not running!"
98dd5d
-		exit $OCF_ERR_CONFIGURED
98dd5d
+		exit $OCF_ERR_GENERIC
98dd5d
 	fi
98dd5d
 
98dd5d
 	if pgrep clvmd >/dev/null 2>&1 ; then
98dd5d
 		ocf_exit_reason "clvmd daemon is running unexpectedly."
98dd5d
-		exit $OCF_ERR_CONFIGURED
98dd5d
+		exit $OCF_ERR_GENERIC
98dd5d
 	fi
98dd5d
 
98dd5d
 	return $OCF_SUCCESS
98dd5d
@@ -402,17 +401,17 @@ clvmd_check()
98dd5d
 	# Good: clvmd is running, and lvmlockd is not running
98dd5d
 	if ! pgrep clvmd >/dev/null 2>&1 ; then
98dd5d
 		ocf_exit_reason "clvmd daemon is not running!"
98dd5d
-		exit $OCF_ERR_CONFIGURED
98dd5d
+		exit $OCF_ERR_GENERIC
98dd5d
 	fi
98dd5d
 
98dd5d
 	if pgrep lvmetad >/dev/null 2>&1 ; then
98dd5d
 		ocf_exit_reason "Please stop lvmetad daemon when clvmd is running."
98dd5d
-		exit $OCF_ERR_CONFIGURED
98dd5d
+		exit $OCF_ERR_GENERIC
98dd5d
 	fi
98dd5d
 
98dd5d
 	if pgrep lvmlockd >/dev/null 2>&1 ; then
98dd5d
 		ocf_exit_reason "lvmlockd daemon is running unexpectedly."
98dd5d
-		exit $OCF_ERR_CONFIGURED
98dd5d
+		exit $OCF_ERR_GENERIC
98dd5d
 	fi
98dd5d
 
98dd5d
 	return $OCF_SUCCESS
98dd5d
@@ -424,12 +423,12 @@ systemid_check()
98dd5d
 	source=$(lvmconfig 'global/system_id_source' 2>/dev/null | cut -d"=" -f2)
98dd5d
 	if [ "$source" = "" ] || [ "$source" = "none" ]; then
98dd5d
 		ocf_exit_reason "system_id_source in lvm.conf is not set correctly!"
98dd5d
-		exit $OCF_ERR_CONFIGURED
98dd5d
+		exit $OCF_ERR_ARGS
98dd5d
 	fi
98dd5d
 
98dd5d
 	if [ -z ${SYSTEM_ID} ]; then
98dd5d
 		ocf_exit_reason "local/system_id is not set!"
98dd5d
-		exit $OCF_ERR_CONFIGURED
98dd5d
+		exit $OCF_ERR_ARGS
98dd5d
 	fi
98dd5d
 
98dd5d
 	return $OCF_SUCCESS
98dd5d
@@ -441,18 +440,18 @@ tagging_check()
98dd5d
 	# The volume_list must be initialized to something in order to
98dd5d
 	# guarantee our tag will be filtered on startup
98dd5d
 	if ! lvm dumpconfig activation/volume_list; then
98dd5d
-		ocf_log err  "LVM: Improper setup detected"
98dd5d
+		ocf_log err "LVM: Improper setup detected"
98dd5d
 		ocf_exit_reason "The volume_list filter must be initialized in lvm.conf for exclusive activation without clvmd"
98dd5d
-		exit $OCF_ERR_CONFIGURED
98dd5d
+		exit $OCF_ERR_ARGS
98dd5d
 	fi
98dd5d
 
98dd5d
 	# Our tag must _NOT_ be in the volume_list.  This agent
98dd5d
 	# overrides the volume_list during activation using the
98dd5d
 	# special tag reserved for cluster activation
98dd5d
 	if lvm dumpconfig activation/volume_list | grep -e "\"@${OUR_TAG}\"" -e "\"${VG}\"";  then
98dd5d
-		ocf_log err "LVM:  Improper setup detected"
98dd5d
+		ocf_log err "LVM: Improper setup detected"
98dd5d
 		ocf_exit_reason "The volume_list in lvm.conf must not contain the cluster tag, \"${OUR_TAG}\", or volume group, ${VG}"
98dd5d
-		exit $OCF_ERR_CONFIGURED
98dd5d
+		exit $OCF_ERR_ARGS
98dd5d
 	fi
98dd5d
 
98dd5d
 	return $OCF_SUCCESS
98dd5d
@@ -463,13 +462,13 @@ read_parameters()
98dd5d
 	if [ -z "$VG" ]
98dd5d
 	then
98dd5d
 		ocf_exit_reason "You must identify the volume group name!"
98dd5d
-		exit $OCF_ERR_ARGS
98dd5d
+		exit $OCF_ERR_CONFIGURED
98dd5d
 	fi
98dd5d
 
98dd5d
 	if [ "$LV_activation_mode" != "shared" ] && [ "$LV_activation_mode" != "exclusive" ]
98dd5d
 	then
98dd5d
 		ocf_exit_reason "Invalid value for activation_mode: $LV_activation_mode"
98dd5d
-		exit $OCF_ERR_ARGS
98dd5d
+		exit $OCF_ERR_CONFIGURED
98dd5d
 	fi
98dd5d
 
98dd5d
 	# Convert VG_access_mode from string to index
98dd5d
@@ -519,8 +518,10 @@ lvm_validate() {
98dd5d
 			exit $OCF_NOT_RUNNING
98dd5d
 		fi
98dd5d
 
98dd5d
+		# Could be a transient error (e.g., iSCSI connection
98dd5d
+		# issue) so use OCF_ERR_GENERIC
98dd5d
 		ocf_exit_reason "Volume group[${VG}] doesn't exist, or not visible on this node!"
98dd5d
-		exit $OCF_ERR_CONFIGURED
98dd5d
+		exit $OCF_ERR_GENERIC
98dd5d
 	fi
98dd5d
 
98dd5d
 	# Inconsistency might be due to missing physical volumes, which doesn't
98dd5d
@@ -549,7 +550,7 @@ lvm_validate() {
98dd5d
 	mode=$?
98dd5d
 	if [ $VG_access_mode_num -ne 4 ] && [ $mode -ne $VG_access_mode_num ]; then
98dd5d
 		ocf_exit_reason "The specified vg_access_mode doesn't match the lock_type on VG metadata!"
98dd5d
-		exit $OCF_ERR_ARGS
98dd5d
+		exit $OCF_ERR_CONFIGURED
98dd5d
 	fi
98dd5d
 
98dd5d
 	# Nothing to do if the VG has no logical volume
98dd5d
@@ -561,11 +562,11 @@ lvm_validate() {
98dd5d
 
98dd5d
 	# Check if the given $LV is in the $VG
98dd5d
 	if [ -n "$LV" ]; then
98dd5d
-		OUT=$(lvs --foreign --noheadings ${VG}/${LV} 2>&1)
98dd5d
+		output=$(lvs --foreign --noheadings ${VG}/${LV} 2>&1)
98dd5d
 		if [ $? -ne 0 ]; then
98dd5d
-			ocf_log err "lvs: ${OUT}"
98dd5d
+			ocf_log err "lvs: ${output}"
98dd5d
 			ocf_exit_reason "LV ($LV) is not in the given VG ($VG)."
98dd5d
-			exit $OCF_ERR_ARGS
98dd5d
+			exit $OCF_ERR_CONFIGURED
98dd5d
 		fi
98dd5d
 	fi
98dd5d
 
98dd5d
@@ -580,7 +581,6 @@ lvm_validate() {
98dd5d
 	3)
98dd5d
 		systemid_check
98dd5d
 		;;
98dd5d
-
98dd5d
 	4)
98dd5d
 		tagging_check
98dd5d
 		;;
98dd5d
@@ -808,10 +808,9 @@ lvm_status() {
98dd5d
 			dd if=${dm_name} of=/dev/null bs=1 count=1 >/dev/null \
98dd5d
 				2>&1
98dd5d
 			if [ $? -ne 0 ]; then
98dd5d
-				return $OCF_NOT_RUNNING
98dd5d
-			else
98dd5d
-				return $OCF_SUCCESS
98dd5d
+				return $OCF_ERR_GENERIC
98dd5d
 			fi
98dd5d
+			return $OCF_SUCCESS
98dd5d
 			;;
98dd5d
 		*)
98dd5d
 			ocf_exit_reason "unsupported monitor level $OCF_CHECK_LEVEL"