Blame SOURCES/0014-Fix-sbd-cluster-periodically-check-corosync-daemon-l.patch

04a57c
From 1387ed890e3a9e246e9b9f780b2a7cb5379459ab Mon Sep 17 00:00:00 2001
04a57c
From: Klaus Wenninger <klaus.wenninger@aon.at>
04a57c
Date: Wed, 5 Jun 2019 11:32:49 +0200
04a57c
Subject: [PATCH] Fix: sbd-cluster: periodically check corosync-daemon liveness
04a57c
04a57c
using votequorum_getinfo.
04a57c
---
04a57c
 configure.ac      | 12 +++++++++++-
04a57c
 src/sbd-cluster.c | 36 ++++++++++++++++++++++++++++++++++--
04a57c
 2 files changed, 45 insertions(+), 3 deletions(-)
04a57c
04a57c
diff --git a/configure.ac b/configure.ac
04a57c
index fac26a8..c44e747 100644
04a57c
--- a/configure.ac
04a57c
+++ b/configure.ac
04a57c
@@ -33,6 +33,7 @@ PKG_CHECK_MODULES(glib, [glib-2.0])
04a57c
 dnl PKG_CHECK_MODULES(libcoroipcc, [libcoroipcc])
04a57c
 
04a57c
 PKG_CHECK_MODULES(cmap, [libcmap], HAVE_cmap=1, HAVE_cmap=0)
04a57c
+PKG_CHECK_MODULES(votequorum, [libvotequorum], HAVE_votequorum=1, HAVE_votequorum=0)
04a57c
 
04a57c
 dnl pacemaker > 1.1.8
04a57c
 PKG_CHECK_MODULES(pacemaker, [pacemaker, pacemaker-cib], HAVE_pacemaker=1, HAVE_pacemaker=0)
04a57c
@@ -49,7 +50,12 @@ elif test $HAVE_pacemaker = 1; then
04a57c
     if test $HAVE_cmap = 0; then
04a57c
         AC_MSG_NOTICE(No package 'cmap' found)
04a57c
     else
04a57c
-	CPPFLAGS="$CPPFLAGS $cmap_CFLAGS"
04a57c
+        CPPFLAGS="$CPPFLAGS $cmap_CFLAGS"
04a57c
+    fi
04a57c
+    if test $HAVE_votequorum = 0; then
04a57c
+        AC_MSG_NOTICE(No library 'votequorum' found)
04a57c
+    else
04a57c
+        CPPFLAGS="$CPPFLAGS $votequorum_CFLAGS"
04a57c
     fi
04a57c
 fi
04a57c
 
04a57c
@@ -66,6 +72,7 @@ AC_CHECK_LIB(pe_rules, test_rule, , missing="yes")
04a57c
 AC_CHECK_LIB(crmcluster, crm_peer_init, , missing="yes")
04a57c
 AC_CHECK_LIB(uuid, uuid_unparse, , missing="yes")
04a57c
 AC_CHECK_LIB(cmap, cmap_initialize, , HAVE_cmap=0)
04a57c
+AC_CHECK_LIB(votequorum, votequorum_getinfo, , HAVE_votequorum=0)
04a57c
 
04a57c
 dnl pacemaker >= 1.1.8
04a57c
 AC_CHECK_HEADERS(pacemaker/crm/cluster.h)
04a57c
@@ -107,6 +114,9 @@ fi
04a57c
 AC_DEFINE_UNQUOTED(CHECK_TWO_NODE, $HAVE_cmap, Turn on checking for 2-node cluster)
04a57c
 AM_CONDITIONAL(CHECK_TWO_NODE, test "$HAVE_cmap" = "1")
04a57c
 
04a57c
+AC_DEFINE_UNQUOTED(CHECK_VOTEQUORUM_HANDLE, $HAVE_votequorum, Turn on periodic checking of votequorum-handle)
04a57c
+AM_CONDITIONAL(CHECK_VOTEQUORUM_HANDLE, test "$HAVE_votequorum" = "1")
04a57c
+
04a57c
 CONFIGDIR=""
04a57c
 AC_ARG_WITH(configdir,
04a57c
     [  --with-configdir=DIR
04a57c
diff --git a/src/sbd-cluster.c b/src/sbd-cluster.c
04a57c
index 541212f..9fb6224 100644
04a57c
--- a/src/sbd-cluster.c
04a57c
+++ b/src/sbd-cluster.c
04a57c
@@ -80,6 +80,12 @@ sbd_plugin_membership_dispatch(cpg_handle_t handle,
04a57c
 
04a57c
 #if SUPPORT_COROSYNC
04a57c
 
04a57c
+#if CHECK_VOTEQUORUM_HANDLE
04a57c
+#include <corosync/votequorum.h>
04a57c
+
04a57c
+static votequorum_handle_t votequorum_handle = 0;
04a57c
+#endif
04a57c
+
04a57c
 static bool two_node = false;
04a57c
 static bool ever_seen_both = false;
04a57c
 static int cpg_membership_entries = -1;
04a57c
@@ -261,12 +267,32 @@ notify_timer_cb(gpointer data)
04a57c
 
04a57c
 #endif
04a57c
         case pcmk_cluster_corosync:
04a57c
+            do {
04a57c
+#if SUPPORT_COROSYNC && CHECK_VOTEQUORUM_HANDLE
04a57c
+                struct votequorum_info info;
04a57c
+
04a57c
+                if (votequorum_getinfo(votequorum_handle, 0, &info) != CS_OK) {
04a57c
+
04a57c
+                    votequorum_finalize(votequorum_handle);
04a57c
+                    if (votequorum_initialize(&votequorum_handle, NULL) != CS_OK) {
04a57c
+                        votequorum_handle = 0;
04a57c
+                        break;
04a57c
+                    }
04a57c
+                    if (votequorum_getinfo(votequorum_handle, 0, &info) != CS_OK) {
04a57c
+                        break;
04a57c
+                    }
04a57c
+                }
04a57c
+#endif
04a57c
+                notify_parent();
04a57c
+            } while (0);
04a57c
+            break;
04a57c
+
04a57c
 #if HAVE_DECL_PCMK_CLUSTER_CMAN
04a57c
         case pcmk_cluster_cman:
04a57c
-#endif
04a57c
-            /* TODO - Make a CPG call and only call notify_parent() when we get a reply */
04a57c
+
04a57c
             notify_parent();
04a57c
             break;
04a57c
+#endif
04a57c
 
04a57c
         default:
04a57c
             break;
04a57c
@@ -533,6 +559,12 @@ find_pacemaker_remote(void)
04a57c
 static void
04a57c
 clean_up(int rc)
04a57c
 {
04a57c
+#if CHECK_VOTEQUORUM_HANDLE
04a57c
+    votequorum_finalize(votequorum_handle);
04a57c
+    votequorum_handle = 0; /* there isn't really an invalid handle value
04a57c
+                            * just to be back where we started
04a57c
+                            */
04a57c
+#endif
04a57c
     return;
04a57c
 }
04a57c
 
04a57c
-- 
04a57c
1.8.3.1
04a57c