[SCM] CTDB repository - branch master updated - ctdb-1.0.114-77-g4a67942

Ronnie Sahlberg sahlberg at samba.org
Mon May 3 21:58:18 MDT 2010


The branch, master has been updated
       via  4a679422dc231aa98605b9cc322e4ab442f7bde4 (commit)
      from  221a9bb41c3a7af0cc65cda78365010893ca1430 (commit)

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


- Log -----------------------------------------------------------------
commit 4a679422dc231aa98605b9cc322e4ab442f7bde4
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue May 4 13:56:55 2010 +1000

    Add a new eventscript 62.cnfs to integrate better with gpfs/cnfs

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

Summary of changes:
 Makefile.in                |    1 +
 config/events.d/62.cnfs    |  129 ++++++++++++++++++++++++++++++++++++++++++++
 packaging/RPM/ctdb.spec.in |    1 +
 3 files changed, 131 insertions(+), 0 deletions(-)
 create mode 100755 config/events.d/62.cnfs


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index d9ecfa7..4e70ce8 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -227,6 +227,7 @@ install: all
 	${INSTALLCMD} -m 755 config/events.d/50.samba $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/60.nfs $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/61.nfstickle $(DESTDIR)$(etcdir)/ctdb/events.d
+	${INSTALLCMD} -m 755 config/events.d/62.cnfs $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/70.iscsi $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/91.lvs $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 tools/ctdb_diagnostics $(DESTDIR)$(bindir)
diff --git a/config/events.d/62.cnfs b/config/events.d/62.cnfs
new file mode 100755
index 0000000..2e01d8a
--- /dev/null
+++ b/config/events.d/62.cnfs
@@ -0,0 +1,129 @@
+#!/bin/sh
+# event script to integrate with gpfs cnfs
+
+. $CTDB_BASE/functions
+
+loadconfig
+
+STATEDIR=$CTDB_BASE/state/gpfs
+
+# filesystems needed by nfs
+NFS_FSS=`cat /etc/exports | egrep -v "^#" | sed -e "s/[ \t]*[^ \t]*$//"`
+
+
+
+check_if_healthy() {
+        mkdir -p $STATEDIR/fs
+        FS=`(cd $STATEDIR/fs ; ls )`
+        [ -z "$FS" ] || {
+                MISSING=`echo $FS | sed -e "s/@/\//g"`
+                logger Filesystems required for NFS are missing. Node is UNHEALTHY. [$MISSING]
+                $CTDB_BASE/events.d/62.cnfs unhealthy "GPFS filesystems required for NFS are not mounted : [$MISSING]"
+                exit 0
+        }
+
+        logger All required GPFS resources are available. CNFS part is healthy.
+        $CTDB_BASE/events.d/62.cnfs healthy
+}
+
+case "$1" in
+    startup)
+        mkdir -p $STATEDIR
+        check_if_healthy
+        ;;
+
+
+    # This event is called from the GPFS callbacks when a filesystem is
+    # unmounted
+    gpfsumount)
+        # is this a filesystem we need for nfs?
+        echo "$NFS_FSS" | egrep "^$2" >/dev/null || {
+                # no
+                exit 0
+        }
+
+        logger "GPFS unmounted filesystem $2 used by NFS. Mark node as UNHEALTHY"
+
+        MFS=`echo $2 | sed -e "s/\//@/g"`
+        mkdir -p $STATEDIR/fs
+        touch "$STATEDIR/fs/$MFS"
+        $CTDB_BASE/events.d/62.cnfs unhealthy "GPFS unmounted filesystem $2 used by NFS"
+        ;;
+
+    # This event is called from the GPFS callbacks when a filesystem is
+    # mounted
+    gpfsmount)
+        # is this a filesystem we need for nfs?
+        echo "$NFS_FSS" | egrep "^$2" >/dev/null || {
+                # no
+                exit 0
+        }
+
+        logger "GPFS mounted filesystem $2 used by NFS."
+
+        MFS=`echo $2 | sed -e "s/\//@/g"`
+        mkdir -p $STATEDIR/fs
+        rm -f "$STATEDIR/fs/$MFS"
+
+        check_if_healthy
+        ;;
+
+
+
+    # This event is called from the gpfs callback when GPFS is being shutdown.
+    gpfsshutdown)
+        logger "GPFS is shutting down. Marking node as UNHEALTHY and trigger a CTDB failover"
+        $CTDB_BASE/events.d/62.cnfs unhealthy "GPFS was shut down!"
+        ;;
+
+
+    # This event is called from the gpfs callback when GPFS has started.
+    # It checks that all required NFS filesystems are mounted 
+    # and flags the node healthy if so.
+    gpfsstartup)
+        logger "GPFS is is started."
+        check_if_healthy
+        ;;
+
+
+
+
+
+    unhealthy)
+        # Mark the node as UNHEALTHY which means all public addresses
+        # will be migrated off the node.
+        shift
+        TMPFILE=/tmp/ctdb.cnfs.$$
+        echo "$*" > $TMPFILE
+        ctdb_setstatus unhealthy $TMPFILE
+        rm $TMPFILE
+
+        # force a monitor event so we pick up immediately that this script
+        # will now fail and make the node unhealthy.
+        ctdb eventscript monitor
+
+        # Wait until we no longer serve any ip addresses at all
+        PNN=`ctdb pnn | cut -d: -f2`
+        while `ctdb -Y ip | cut -d: -f3 | egrep "^$PNN$" >/dev/null`; do
+                sleep 1
+        done
+        ;;
+
+    healthy)
+        # mark the node as healthy
+        ctdb_setstatus healthy
+        ;;
+
+
+    monitor)
+        ctdb_checkstatus
+        exit $?
+        ;;
+
+    *)
+        ctdb_standard_event_handler "$@"
+        ;;
+esac
+
+exit 0
+
diff --git a/packaging/RPM/ctdb.spec.in b/packaging/RPM/ctdb.spec.in
index f23943f..8da7944 100644
--- a/packaging/RPM/ctdb.spec.in
+++ b/packaging/RPM/ctdb.spec.in
@@ -107,6 +107,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_sysconfdir}/ctdb/events.d/50.samba
 %{_sysconfdir}/ctdb/events.d/60.nfs
 %{_sysconfdir}/ctdb/events.d/61.nfstickle
+%{_sysconfdir}/ctdb/events.d/62.cnfs
 %{_sysconfdir}/ctdb/events.d/70.iscsi
 %{_sysconfdir}/ctdb/events.d/91.lvs
 %{_sysconfdir}/ctdb/statd-callout


-- 
CTDB repository


More information about the samba-cvs mailing list