resource-agents/SOURCES/bz1902208-LVM-activate-stop...

61 lines
2.0 KiB
Diff

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