This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

master - cman notifyd: export quorum information on statechange


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=961ccff86125181bdcb4f509c8a69741fdc6d30c
Commit:        961ccff86125181bdcb4f509c8a69741fdc6d30c
Parent:        e879db770593a7535dfc0f39a874f99053749096
Author:        Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate:    Tue Nov 4 10:43:24 2008 +0100
Committer:     Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Tue Nov 4 10:43:24 2008 +0100

cman notifyd: export quorum information on statechange

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
 cman/man/cmannotifyd.8      |    4 ++++
 cman/notifyd/main.c         |   12 +++++++++---
 doc/cman_notify_template.sh |    8 ++++++++
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/cman/man/cmannotifyd.8 b/cman/man/cmannotifyd.8
index 8712654..cbbd89c 100644
--- a/cman/man/cmannotifyd.8
+++ b/cman/man/cmannotifyd.8
@@ -53,6 +53,10 @@ arrive, one by one.
 CMAN_REASON_TRY_SHUTDOWN is passed to scripts for information only, they
 can not influence cman's decsion about whether or not to shut down.
 
+CMAN_REASON_STATECHANGE also implies CMAN_NOTIFICATION_QUORUM exported
+in the environment. CMAN_NOTIFICATION_QUORUM can be set to 1 (when the node
+is part of a quored cluster) or 0 (otherwise).
+
 A template for cman_notify scripts can be found in the doc/ directory.
 
 .SH "OPTIONS"
diff --git a/cman/notifyd/main.c b/cman/notifyd/main.c
index 870e2df..173cb64 100644
--- a/cman/notifyd/main.c
+++ b/cman/notifyd/main.c
@@ -201,7 +201,7 @@ static void init_logging(int reconf)
 		logt_conf("CMANNOTIFYD", mode, facility, priority, file);
 }
 
-static void dispatch_notification(char *str)
+static void dispatch_notification(char *str, int *quorum)
 {
 	char *envp[MAX_ARGS];
 	char *argv[MAX_ARGS];
@@ -218,6 +218,11 @@ static void dispatch_notification(char *str)
 	snprintf(scratch, sizeof(scratch), "CMAN_NOTIFICATION=%s", str);
 	envp[envptr++] = strdup(scratch);
 
+	if (quorum) {
+		snprintf(scratch, sizeof(scratch), "CMAN_NOTIFICATION_QUORUM=%d", *quorum);
+		envp[envptr++] = strdup(scratch);
+	}
+
 	if (debug)
 		envp[envptr++] = strdup("CMAN_NOTIFICATION_DEBUG=1");
 
@@ -256,21 +261,22 @@ static void cman_callback(cman_handle_t ch, void *private, int reason, int arg)
 		logt_print(LOG_DEBUG, "Received a cman shutdown request\n");
 		cman_replyto_shutdown(ch, 1);	/* allow cman to shutdown */
 		str = "CMAN_REASON_TRY_SHUTDOWN";
+		dispatch_notification(str, 0);
 		break;
 	case CMAN_REASON_STATECHANGE:
 		logt_print(LOG_DEBUG,
 			   "Received a cman statechange notification\n");
 		str = "CMAN_REASON_STATECHANGE";
+		dispatch_notification(str, &arg);
 		break;
 	case CMAN_REASON_CONFIG_UPDATE:
 		logt_print(LOG_DEBUG,
 			   "Received a cman config update notification\n");
 		init_logging(1);
 		str = "CMAN_REASON_CONFIG_UPDATE";
+		dispatch_notification(str, 0);
 		break;
 	}
-
-	dispatch_notification(str);
 }
 
 static void byebye_cman()
diff --git a/doc/cman_notify_template.sh b/doc/cman_notify_template.sh
index 0d32003..208d2a5 100644
--- a/doc/cman_notify_template.sh
+++ b/doc/cman_notify_template.sh
@@ -34,6 +34,14 @@ case "$CMAN_NOTIFICATION" in
 		# we received a status change. A node might have left or joined
 		# the cluster
 		my_echo "replace me with something to do"
+
+		# STATECHANGE contains information about the quorum status of
+		# the node.
+		# 1 = the node is part of a quorated cluster
+		# 0 = there is no quorum
+		if [ "$CMAN_NOTIFICATION_QUORUM" = "1" ]; then
+			my_echo "we still have quorum"
+		fi
 	;;
 	CMAN_REASON_TRY_SHUTDOWN)
 		# we received a shutdown request. It means that cman might go


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]