1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-09 08:58:35 +03:00

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

(This used to be ctdb commit 4a679422dc231aa98605b9cc322e4ab442f7bde4)
This commit is contained in:
Ronnie Sahlberg 2010-05-04 13:56:55 +10:00
parent 46f00a2478
commit 1cb2b0b2d0
3 changed files with 131 additions and 0 deletions

View File

@ -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)

129
ctdb/config/events.d/62.cnfs Executable file
View File

@ -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

View File

@ -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