Blame SOURCES/bz1902208-LVM-activate-stop-before-storage-service.patch

030326
From 79fb4b2d3d862f4e83b1df72107b6322b420ea34 Mon Sep 17 00:00:00 2001
030326
From: Reid Wahl <nrwahl@protonmail.com>
030326
Date: Sat, 28 Nov 2020 18:10:03 -0800
030326
Subject: [PATCH] LVM-activate: Stop before blk-availability.service
030326
030326
If storage services (e.g., iscsi-shutdown.service) stop before an
030326
LVM-activate resource stops, the managed VG may become unavailable. Then
030326
the LVM-activate resource may fail to deactivate the volume group and
030326
thus fail its stop operation.
030326
030326
This commit adds a systemd drop-in "After=blk-availability.service"
030326
directive for resource-agents-deps.target during the LVM-activate start
030326
op. blk-availability includes "After=" directives for other storage
030326
services and thus serves as a convenient wrapper.
030326
030326
blk-availability is not enabled by default, and a "Wants=" drop-in
030326
that's created after Pacemaker starts would not be able to start
030326
blk-availability automatically. So here we also start blk-availability
030326
during LVM_start().
030326
030326
Resolves RHBZ#1902208
030326
030326
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
030326
---
030326
 heartbeat/LVM-activate | 22 ++++++++++++++++++++++
030326
 1 file changed, 22 insertions(+)
030326
030326
diff --git a/heartbeat/LVM-activate b/heartbeat/LVM-activate
030326
index 94f9e5813..b8abd7579 100755
030326
--- a/heartbeat/LVM-activate
030326
+++ b/heartbeat/LVM-activate
030326
@@ -830,6 +830,28 @@ lvm_start() {
030326
 	local rc
030326
 	local vol
030326
 
030326
+        if systemd_is_running ; then
030326
+        	# Create drop-in to deactivate VG before stopping
030326
+		# storage services during shutdown/reboot.
030326
+		after=$(systemctl show resource-agents-deps.target.d \
030326
+			--property=After | cut -d'=' -f2)
030326
+
030326
+		case "$after" in
030326
+			*" blk-availability.service "*)
030326
+				;;
030326
+			*)
030326
+				systemd_drop_in "99-LVM-activate" "After" \
030326
+					"blk-availability.service"
030326
+				;;
030326
+		esac
030326
+
030326
+		# If blk-availability isn't started, the "After="
030326
+		# directive has no effect.
030326
+		if ! systemctl is-active blk-availability.service ; then
030326
+			systemctl start blk-availability.service
030326
+		fi
030326
+        fi
030326
+
030326
 	if lvm_status ; then
030326
 		ocf_log info "${vol}: is already active."
030326
 		return $OCF_SUCCESS