Blob Blame History Raw
From f4d38a073ce3bfa2078792f1cc85229457430292 Mon Sep 17 00:00:00 2001
From: Klaus Wenninger <klaus.wenninger@aon.at>
Date: Tue, 21 Jul 2020 18:30:30 +0200
Subject: [PATCH] Fix: make syncing of pacemaker resource startup configurable

---
 src/sbd-inquisitor.c | 20 ++++++++++++++++++++
 src/sbd-pacemaker.c  |  6 +++---
 src/sbd.h            |  1 +
 src/sbd.sysconfig    | 14 ++++++++++++++
 4 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/src/sbd-inquisitor.c b/src/sbd-inquisitor.c
index 52ede8a..962725e 100644
--- a/src/sbd-inquisitor.c
+++ b/src/sbd-inquisitor.c
@@ -35,6 +35,7 @@ bool do_flush = true;
 char timeout_sysrq_char = 'b';
 bool move_to_root_cgroup = true;
 bool enforce_moving_to_root_cgroup = false;
+bool sync_resource_startup = false;
 
 int parse_device_line(const char *line);
 
@@ -964,6 +965,25 @@ int main(int argc, char **argv, char **envp)
             }
         }
 
+        value = getenv("SBD_SYNC_RESOURCE_STARTUP");
+        if(value) {
+            sync_resource_startup = crm_is_true(value);
+        }
+#if !USE_PACEMAKERD_API
+        if (sync_resource_startup) {
+            fprintf(stderr, "Failed to sync resource-startup as "
+                "SBD was built against pacemaker not supporting pacemakerd-API.\n");
+            exit_status = -1;
+            goto out;
+        }
+#else
+        if (!sync_resource_startup) {
+            cl_log(LOG_WARNING, "SBD built against pacemaker supporting "
+                             "pacemakerd-API. Should think about enabling "
+                             "SBD_SYNC_RESOURCE_STARTUP.");
+        }
+#endif
+
 	while ((c = getopt(argc, argv, "czC:DPRTWZhvw:d:n:p:1:2:3:4:5:t:I:F:S:s:r:")) != -1) {
 		switch (c) {
 		case 'D':
diff --git a/src/sbd-pacemaker.c b/src/sbd-pacemaker.c
index 1243bfc..aa1fb57 100644
--- a/src/sbd-pacemaker.c
+++ b/src/sbd-pacemaker.c
@@ -190,12 +190,12 @@ mon_cib_connection_destroy(gpointer user_data)
 		/* retrigger as last one might have been skipped */
 		mon_refresh_state(NULL);
 
-#if !USE_PACEMAKERD_API
-		if (pcmk_clean_shutdown) {
+
+		if ((pcmk_clean_shutdown) && (!sync_resource_startup)) {
 			/* assume a graceful pacemaker-shutdown */
 			clean_up(EXIT_PCMK_SERVANT_GRACEFUL_SHUTDOWN);
 		}
-#endif
+
 		/* getting here we aren't sure about the pacemaker-state
 		   so try to use the timeout to reconnect and get
 		   everything sorted out again
diff --git a/src/sbd.h b/src/sbd.h
index 382e553..3b6647c 100644
--- a/src/sbd.h
+++ b/src/sbd.h
@@ -161,6 +161,7 @@ extern bool do_flush;
 extern char timeout_sysrq_char;
 extern bool move_to_root_cgroup;
 extern bool enforce_moving_to_root_cgroup;
+extern bool sync_resource_startup;
 
 /* Global, non-tunable variables: */
 extern int  sector_size;
diff --git a/src/sbd.sysconfig b/src/sbd.sysconfig
index 33b50d0..b32e826 100644
--- a/src/sbd.sysconfig
+++ b/src/sbd.sysconfig
@@ -106,6 +106,20 @@ SBD_TIMEOUT_ACTION=flush,reboot
 #
 SBD_MOVE_TO_ROOT_CGROUP=auto
 
+## Type: yesno
+## Default: no
+#
+# If resource startup syncing is enabled then pacemakerd is
+# gonna wait to be pinged via IPC before it starts resources.
+# On shutdown pacemakerd is going to wait in a state where it
+# has cleanly shutdown resources till sbd fetches that state.
+#
+# Default is 'no' to prevent pacemaker from waiting for a
+# ping that will never come when working together with an sbd
+# version that doesn't support the feature.
+#
+SBD_SYNC_RESOURCE_STARTUP=no
+
 ## Type: string
 ## Default: ""
 #
-- 
1.8.3.1