Skip to content

Commit

Permalink
Fix: sbd-cluster: periodically check corosync-daemon liveness
Browse files Browse the repository at this point in the history
using votequorum_getinfo.
  • Loading branch information
wenningerk committed Jun 5, 2019
1 parent 6ee2dc1 commit 93208e4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
12 changes: 11 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ PKG_CHECK_MODULES(glib, [glib-2.0])
dnl PKG_CHECK_MODULES(libcoroipcc, [libcoroipcc])

PKG_CHECK_MODULES(cmap, [libcmap], HAVE_cmap=1, HAVE_cmap=0)
PKG_CHECK_MODULES(votequorum, [libvotequorum], HAVE_votequorum=1, HAVE_votequorum=0)

dnl pacemaker > 1.1.8
PKG_CHECK_MODULES(pacemaker, [pacemaker, pacemaker-cib], HAVE_pacemaker=1, HAVE_pacemaker=0)
Expand All @@ -49,7 +50,12 @@ elif test $HAVE_pacemaker = 1; then
if test $HAVE_cmap = 0; then
AC_MSG_NOTICE(No package 'cmap' found)
else
CPPFLAGS="$CPPFLAGS $cmap_CFLAGS"
CPPFLAGS="$CPPFLAGS $cmap_CFLAGS"
fi
if test $HAVE_votequorum = 0; then
AC_MSG_NOTICE(No package 'votequorum' found)
else
CPPFLAGS="$CPPFLAGS $votequorum_CFLAGS"
fi
fi

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

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

AC_DEFINE_UNQUOTED(CHECK_VOTEQUORUM_HANDLE, $HAVE_votequorum, Turn on periodic checking of votequorum-handle)
AM_CONDITIONAL(CHECK_VOTEQUORUM_HANDLE, test "$HAVE_votequorum" = "1")

CONFIGDIR=""
AC_ARG_WITH(configdir,
[ --with-configdir=DIR
Expand Down
36 changes: 34 additions & 2 deletions src/sbd-cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ sbd_plugin_membership_dispatch(cpg_handle_t handle,

#if SUPPORT_COROSYNC

#if CHECK_VOTEQUORUM_HANDLE
#include <corosync/votequorum.h>

static votequorum_handle_t votequorum_handle = 0;
#endif

static bool two_node = false;
static bool ever_seen_both = false;
static int cpg_membership_entries = -1;
Expand Down Expand Up @@ -261,12 +267,32 @@ notify_timer_cb(gpointer data)

#endif
case pcmk_cluster_corosync:
do {
#if SUPPORT_COROSYNC && CHECK_VOTEQUORUM_HANDLE
struct votequorum_info info;

if (votequorum_getinfo(votequorum_handle, 0, &info) != CS_OK) {

votequorum_finalize(votequorum_handle);
if (votequorum_initialize(&votequorum_handle, NULL) != CS_OK) {
votequorum_handle = 0;
break;
}
if (votequorum_getinfo(votequorum_handle, 0, &info) != CS_OK) {
break;
}
}
#endif
notify_parent();
} while (0);
break;

#if HAVE_DECL_PCMK_CLUSTER_CMAN
case pcmk_cluster_cman:
#endif
/* TODO - Make a CPG call and only call notify_parent() when we get a reply */

notify_parent();
break;
#endif

default:
break;
Expand Down Expand Up @@ -533,6 +559,12 @@ find_pacemaker_remote(void)
static void
clean_up(int rc)
{
#if CHECK_VOTEQUORUM_HANDLE
votequorum_finalize(votequorum_handle);
votequorum_handle = 0; /* there isn't really an invalid handle value
* just to be back where we started
*/
#endif
return;
}

Expand Down

0 comments on commit 93208e4

Please sign in to comment.