New version 1.0.112-19
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 4 May 2010 03:50:26 +0000 (13:50 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 4 May 2010 03:50:26 +0000 (13:50 +1000)
This version adds a new eventscript 62.cnfs that
allows better integration with GPFS.

BZ 61913

Makefile.in
config/events.d/62.cnfs [new file with mode: 0755]
packaging/RPM/ctdb.spec.in

index 054c1e098490e2819e821081d2ab10006a04dccd..869c364d07954c542da97aea48badeaba5d8908e 100755 (executable)
@@ -224,6 +224,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 (executable)
index 0000000..2e01d8a
--- /dev/null
@@ -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
+
index fa7bf348f133104205560f451af044625284ef45..1e9c74c23b5b8610bb65c4e14641f60649cad319 100644 (file)
@@ -5,7 +5,7 @@ Vendor: Samba Team
 Packager: Samba Team <samba@samba.org>
 Name: ctdb
 Version: 1.0.112
-Release: 18
+Release: 19
 Epoch: 0
 License: GNU GPL version 3
 Group: System Environment/Daemons
@@ -105,6 +105,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
@@ -124,6 +125,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_docdir}/ctdb/tests/bin/ctdb_transaction
 
 %changelog
+* Tue May 4 2010 : Version 1.0.112-19
+ - Add an eventscript 62.cnfs to allow better integration with GPFS.
+   BZ 61913
 * Mon May 3 2010 : Version 1.0.112-18
  - Make the NATGW eventscript check for when the system is misconfigured
    to use the same address for both natgw as well as a public address