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

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