Blame SOURCES/bz1759068-LVM-activate-partial-activation.patch

5c52dd
diff -uNr a/heartbeat/LVM-activate b/heartbeat/LVM-activate
5c52dd
--- a/heartbeat/LVM-activate	2019-10-08 12:10:11.755991580 +0200
5c52dd
+++ b/heartbeat/LVM-activate	2019-10-08 12:14:38.388288176 +0200
5c52dd
@@ -42,6 +42,11 @@
5c52dd
 : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
5c52dd
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
5c52dd
 
5c52dd
+# Parameter defaults
5c52dd
+OCF_RESKEY_partial_activation_default="false"
5c52dd
+
5c52dd
+: ${OCF_RESKEY_partial_activation=${OCF_RESKEY_partial_activation_default}}
5c52dd
+
5c52dd
 # If LV is given, only activate this named LV; otherwise, activate all
5c52dd
 # LVs in the named VG.
5c52dd
 VG=${OCF_RESKEY_vgname}
5c52dd
@@ -150,6 +155,16 @@
5c52dd
 <content type="string" default="pacemaker" />
5c52dd
 </parameter>
5c52dd
 
5c52dd
+<parameter name="partial_activation" unique="0" required="0">
5c52dd
+<longdesc lang="en">
5c52dd
+If set, the volume group will be activated partially even with some
5c52dd
+physical volumes missing. It helps to set to true when using mirrored
5c52dd
+logical volumes.
5c52dd
+</longdesc>
5c52dd
+<shortdesc lang="en">Activate VG partially when missing PVs</shortdesc>
5c52dd
+<content type="string" default="${OCF_RESKEY_partial_activation_default}" />
5c52dd
+</parameter>
5c52dd
+
5c52dd
 </parameters>
5c52dd
 
5c52dd
 <actions>
5c52dd
@@ -486,6 +501,25 @@
5c52dd
 		exit $OCF_ERR_CONFIGURED
5c52dd
 	fi
5c52dd
 
5c52dd
+	# Inconsistency might be due to missing physical volumes, which doesn't
5c52dd
+	# automatically mean we should fail.  If partial_activation=true then
5c52dd
+	# we should let start try to handle it, or if no PVs are listed as
5c52dd
+	# "unknown device" then another node may have marked a device missing
5c52dd
+	# where we have access to all of them and can start without issue.
5c52dd
+	case $(vgs -o attr --noheadings $VG | tr -d ' ') in
5c52dd
+	???p??*)
5c52dd
+		if ! ocf_is_true "$OCF_RESKEY_partial_activation" ; then
5c52dd
+			# We are missing devices and cannot activate partially
5c52dd
+			ocf_exit_reason "Volume group [$VG] has devices missing.  Consider partial_activation=true to attempt to activate partially"
5c52dd
+			exit $OCF_ERR_GENERIC
5c52dd
+		else
5c52dd
+			# We are missing devices but are allowed to activate partially.
5c52dd
+			# Assume that caused the vgck failure and carry on
5c52dd
+			ocf_log warn "Volume group inconsistency detected with missing device(s) and partial_activation enabled.  Proceeding with requested action."
5c52dd
+		fi
5c52dd
+		;;
5c52dd
+	esac
5c52dd
+
5c52dd
 	# Get the access mode from VG metadata and check if it matches the input
5c52dd
 	# value. Skip to check "tagging" mode because there's no reliable way to
5c52dd
 	# automatically check if "tagging" mode is being used.
5c52dd
@@ -545,6 +579,10 @@
5c52dd
 do_activate() {
5c52dd
 	local activate_opt=$1
5c52dd
 
5c52dd
+	if ocf_is_true "$OCF_RESKEY_partial_activation" ; then
5c52dd
+		activate_opt="${activate_opt} --partial"
5c52dd
+	fi
5c52dd
+
5c52dd
 	# Only activate the specific LV if it's given
5c52dd
 	if [ -n "$LV" ]; then
5c52dd
 		ocf_run lvchange $activate_opt ${VG}/${LV}