From 2be8fd75ffb3de15c6c882462e7523bea7b8f528 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Mon, 30 Aug 2010 00:12:10 +0000 Subject: [PATCH] Execute hook when split-brain is detected. MFC after: 2 weeks Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com --- sbin/hastd/hast.conf.5 | 5 +++++ sbin/hastd/primary.c | 3 +++ sbin/hastd/secondary.c | 2 ++ 3 files changed, 10 insertions(+) diff --git a/sbin/hastd/hast.conf.5 b/sbin/hastd/hast.conf.5 index 0707115e7228..f12768ed7cc9 100644 --- a/sbin/hastd/hast.conf.5 +++ b/sbin/hastd/hast.conf.5 @@ -232,6 +232,11 @@ between the nodes. .Pp Executed on both primary and secondary nodes when resource role is changed. .Pp +.It Ic " split-brain " +.Pp +Executed on both primary and secondary nodes when split-brain condition is +detected. +.Pp .El The .Aq path diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c index 088a272610b8..73155a180d87 100644 --- a/sbin/hastd/primary.c +++ b/sbin/hastd/primary.c @@ -498,6 +498,7 @@ init_remote(struct hast_resource *res, struct proto_conn **inp, assert(real_remote(res)); in = out = NULL; + errmsg = NULL; /* Prepare outgoing connection with remote node. */ if (proto_client(res->hr_remoteaddr, &out) < 0) { @@ -673,6 +674,8 @@ init_remote(struct hast_resource *res, struct proto_conn **inp, } return (true); close: + if (errmsg != NULL && strcmp(errmsg, "Split-brain condition!") == 0) + hook_exec(res->hr_exec, "split-brain", res->hr_name, NULL); proto_close(out); if (in != NULL) proto_close(in); diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c index 6051722ed39d..d92030cfb195 100644 --- a/sbin/hastd/secondary.c +++ b/sbin/hastd/secondary.c @@ -323,6 +323,7 @@ init_remote(struct hast_resource *res, struct nv *nvin) if (res->hr_secondary_localcnt > res->hr_primary_remotecnt && res->hr_primary_localcnt > res->hr_secondary_remotecnt) { /* Exit on split-brain. */ + hook_exec(res->hr_exec, "split-brain", res->hr_name, NULL); exit(EX_CONFIG); } } @@ -373,6 +374,7 @@ hastd_secondary(struct hast_resource *res, struct nv *nvin) if (proto_timeout(res->hr_remoteout, res->hr_timeout) < 0) pjdlog_errno(LOG_WARNING, "Unable to set connection timeout"); + hook_init(); init_local(res); init_remote(res, nvin); init_environment();