[SCM] CTDB repository - branch master updated - ctdb-1.0.90-26-g6e35feb

Ronnie Sahlberg sahlberg at samba.org
Sun Sep 27 22:15:25 MDT 2009


The branch, master has been updated
       via  6e35feb06ec036b9036c5d1cdd94f7cef140d8a6 (commit)
       via  2cb04747887674def299e574fccb827c1c3194e7 (commit)
       via  5e7dc36f1649824db2f9dab34bede8b388502a57 (commit)
      from  edb58a417bfeb094cbbbf96caec8e2918256dad9 (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 6e35feb06ec036b9036c5d1cdd94f7cef140d8a6
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Sep 28 14:12:59 2009 +1000

    change the reclock fail count to 19 monitor intervals before we shut down ctdbd

commit 2cb04747887674def299e574fccb827c1c3194e7
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Sep 28 14:06:40 2009 +1000

        add a new eventscript 01.reclock
    
        if the reclock file has been set, then this script will test that the
        reclock file can actually be accessed.
        if the file does not exist, or if the attempts to stat the file hangs,
        the node will be marked unhealthy after the third failed monitoring event
        and after the tenth failure, ctdb itself will shutdown.

commit 5e7dc36f1649824db2f9dab34bede8b388502a57
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Sep 28 13:39:54 2009 +1000

    add machinereadable output for the ctdb getreclock command

-----------------------------------------------------------------------

Summary of changes:
 Makefile.in                |    1 +
 config/events.d/01.reclock |   58 ++++++++++++++++++++++++++++++++++++++++++++
 packaging/RPM/ctdb.spec    |    1 +
 tools/ctdb.c               |   12 +++++++--
 4 files changed, 69 insertions(+), 3 deletions(-)
 create mode 100755 config/events.d/01.reclock


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index cda8ec2..88f6eae 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -207,6 +207,7 @@ install: all
 	${INSTALLCMD} -m 644 config/events.d/README $(DESTDIR)$(docdir)/ctdb/README.eventscripts
 	${INSTALLCMD} -m 644 doc/recovery-process.txt $(DESTDIR)$(docdir)/ctdb/recovery-process.txt
 	${INSTALLCMD} -m 755 config/events.d/00.ctdb $(DESTDIR)$(etcdir)/ctdb/events.d
+	${INSTALLCMD} -m 755 config/events.d/01.reclock $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/10.interface $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/11.natgw $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/11.routing $(DESTDIR)$(etcdir)/ctdb/events.d
diff --git a/config/events.d/01.reclock b/config/events.d/01.reclock
new file mode 100755
index 0000000..ccc0075
--- /dev/null
+++ b/config/events.d/01.reclock
@@ -0,0 +1,58 @@
+#!/bin/sh
+# script to check accessibility to the reclock file on a node
+
+. $CTDB_BASE/functions
+loadconfig ctdb
+
+cmd="$1"
+shift
+
+PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
+
+# The size of this file represents the number of intervals that have
+# passed when we have tried to but failed to stat the reclock file.
+# after third failure the node becomes unhealthy
+# after the twenteth failure the node we shutdown ctdbd
+RECLOCKCOUNT="$CTDB_BASE/state/reclock-fail-count"
+
+case $cmd in 
+     startup)
+	echo -n > $RECLOCKCOUNT
+	;;
+
+      monitor)
+	echo -n 1 >> $RECLOCKCOUNT
+
+	COUNT=`ls -ln $RECLOCKCOUNT | cut -d" " -f5`
+	[ $COUNT -gt 19 ] && {
+		echo "Reclock file can not be accessed. Shutting down."
+		sleep 1
+		ctdb shutdown
+	}
+
+	RECLOCKFILE=`ctdb -Y getreclock`
+	[ -z $RECLOCKFILE ] && {
+		# we are not using a reclock file
+		echo -n > $RECLOCKCOUNT
+		exit 0
+	}
+
+	# try stat the reclock file as a background process
+	# so that we dont block in case the cluster filesystem is unavailable
+	(
+		stat $RECLOCKFILE
+		[ "$?" -eq 0 ] && {
+			# we could stat the file, reset the counter
+			echo -n > $RECLOCKCOUNT
+		}
+	) >/dev/null 2>/dev/null &
+
+
+	[ $COUNT -gt 2 ] && {
+		echo "Reclock file can not be accessed. Mark node UNHEALTHY."
+		exit 1;
+	}
+	;;
+esac
+
+exit 0
diff --git a/packaging/RPM/ctdb.spec b/packaging/RPM/ctdb.spec
index 7655e30..0954f74 100644
--- a/packaging/RPM/ctdb.spec
+++ b/packaging/RPM/ctdb.spec
@@ -104,6 +104,7 @@ fi
 %{_docdir}/ctdb/README.eventscripts
 %{_docdir}/ctdb/recovery-process.txt
 %{_sysconfdir}/ctdb/events.d/00.ctdb
+%{_sysconfdir}/ctdb/events.d/01.reclock
 %{_sysconfdir}/ctdb/events.d/10.interface
 %{_sysconfdir}/ctdb/events.d/11.natgw
 %{_sysconfdir}/ctdb/events.d/11.routing
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 0b263f2..223be3f 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -2529,10 +2529,16 @@ static int control_getreclock(struct ctdb_context *ctdb, int argc, const char **
 		DEBUG(DEBUG_ERR, ("Unable to get reclock file from node %u\n", options.pnn));
 		return ret;
 	} else {
-		if (reclock == NULL) {
-			printf("No reclock file used.\n");
+		if (options.machinereadable){
+			if (reclock != NULL) {
+				printf("%s", reclock);
+			}
 		} else {
-			printf("Reclock file:%s\n", reclock);
+			if (reclock == NULL) {
+				printf("No reclock file used.\n");
+			} else {
+				printf("Reclock file:%s\n", reclock);
+			}
 		}
 	}
 	return 0;


-- 
CTDB repository


More information about the samba-cvs mailing list