Skip to content

Commit 93208e4

Browse files
committed
Fix: sbd-cluster: periodically check corosync-daemon liveness
using votequorum_getinfo.
1 parent 6ee2dc1 commit 93208e4

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

configure.ac

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ PKG_CHECK_MODULES(glib, [glib-2.0])
3333
dnl PKG_CHECK_MODULES(libcoroipcc, [libcoroipcc])
3434

3535
PKG_CHECK_MODULES(cmap, [libcmap], HAVE_cmap=1, HAVE_cmap=0)
36+
PKG_CHECK_MODULES(votequorum, [libvotequorum], HAVE_votequorum=1, HAVE_votequorum=0)
3637

3738
dnl pacemaker > 1.1.8
3839
PKG_CHECK_MODULES(pacemaker, [pacemaker, pacemaker-cib], HAVE_pacemaker=1, HAVE_pacemaker=0)
@@ -49,7 +50,12 @@ elif test $HAVE_pacemaker = 1; then
4950
if test $HAVE_cmap = 0; then
5051
AC_MSG_NOTICE(No package 'cmap' found)
5152
else
52-
CPPFLAGS="$CPPFLAGS $cmap_CFLAGS"
53+
CPPFLAGS="$CPPFLAGS $cmap_CFLAGS"
54+
fi
55+
if test $HAVE_votequorum = 0; then
56+
AC_MSG_NOTICE(No package 'votequorum' found)
57+
else
58+
CPPFLAGS="$CPPFLAGS $votequorum_CFLAGS"
5359
fi
5460
fi
5561

@@ -66,6 +72,7 @@ AC_CHECK_LIB(pe_rules, test_rule, , missing="yes")
6672
AC_CHECK_LIB(crmcluster, crm_peer_init, , missing="yes")
6773
AC_CHECK_LIB(uuid, uuid_unparse, , missing="yes")
6874
AC_CHECK_LIB(cmap, cmap_initialize, , HAVE_cmap=0)
75+
AC_CHECK_LIB(votequorum, votequorum_getinfo, , HAVE_votequorum=0)
6976

7077
dnl pacemaker >= 1.1.8
7178
AC_CHECK_HEADERS(pacemaker/crm/cluster.h)
@@ -107,6 +114,9 @@ fi
107114
AC_DEFINE_UNQUOTED(CHECK_TWO_NODE, $HAVE_cmap, Turn on checking for 2-node cluster)
108115
AM_CONDITIONAL(CHECK_TWO_NODE, test "$HAVE_cmap" = "1")
109116

117+
AC_DEFINE_UNQUOTED(CHECK_VOTEQUORUM_HANDLE, $HAVE_votequorum, Turn on periodic checking of votequorum-handle)
118+
AM_CONDITIONAL(CHECK_VOTEQUORUM_HANDLE, test "$HAVE_votequorum" = "1")
119+
110120
CONFIGDIR=""
111121
AC_ARG_WITH(configdir,
112122
[ --with-configdir=DIR

src/sbd-cluster.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ sbd_plugin_membership_dispatch(cpg_handle_t handle,
8080

8181
#if SUPPORT_COROSYNC
8282

83+
#if CHECK_VOTEQUORUM_HANDLE
84+
#include <corosync/votequorum.h>
85+
86+
static votequorum_handle_t votequorum_handle = 0;
87+
#endif
88+
8389
static bool two_node = false;
8490
static bool ever_seen_both = false;
8591
static int cpg_membership_entries = -1;
@@ -261,12 +267,32 @@ notify_timer_cb(gpointer data)
261267

262268
#endif
263269
case pcmk_cluster_corosync:
270+
do {
271+
#if SUPPORT_COROSYNC && CHECK_VOTEQUORUM_HANDLE
272+
struct votequorum_info info;
273+
274+
if (votequorum_getinfo(votequorum_handle, 0, &info) != CS_OK) {
275+
276+
votequorum_finalize(votequorum_handle);
277+
if (votequorum_initialize(&votequorum_handle, NULL) != CS_OK) {
278+
votequorum_handle = 0;
279+
break;
280+
}
281+
if (votequorum_getinfo(votequorum_handle, 0, &info) != CS_OK) {
282+
break;
283+
}
284+
}
285+
#endif
286+
notify_parent();
287+
} while (0);
288+
break;
289+
264290
#if HAVE_DECL_PCMK_CLUSTER_CMAN
265291
case pcmk_cluster_cman:
266-
#endif
267-
/* TODO - Make a CPG call and only call notify_parent() when we get a reply */
292+
268293
notify_parent();
269294
break;
295+
#endif
270296

271297
default:
272298
break;
@@ -533,6 +559,12 @@ find_pacemaker_remote(void)
533559
static void
534560
clean_up(int rc)
535561
{
562+
#if CHECK_VOTEQUORUM_HANDLE
563+
votequorum_finalize(votequorum_handle);
564+
votequorum_handle = 0; /* there isn't really an invalid handle value
565+
* just to be back where we started
566+
*/
567+
#endif
536568
return;
537569
}
538570

0 commit comments

Comments
 (0)