ctdb-scripts: Add portmapper NFS .check file
authorMartin Schwenke <martin@meltin.net>
Mon, 13 Jul 2015 11:00:29 +0000 (21:00 +1000)
committerAmitay Isaacs <amitay@samba.org>
Tue, 14 Jul 2015 07:57:18 +0000 (09:57 +0200)
Unhealthy after 1 failed attempt to contact the portmapper.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/nfs-checks.d/00.portmapper.check [new file with mode: 0644]
ctdb/packaging/RPM/ctdb.spec.in
ctdb/tests/eventscripts/60.nfs.monitor.106.sh [new file with mode: 0755]
ctdb/tests/eventscripts/scripts/local.sh

diff --git a/ctdb/config/nfs-checks.d/00.portmapper.check b/ctdb/config/nfs-checks.d/00.portmapper.check
new file mode 100644 (file)
index 0000000..24def35
--- /dev/null
@@ -0,0 +1,2 @@
+# portmapper
+unhealthy_after=1
index d7c816ef3892de3c1215201752392e254b45ea1c..c356b6c21d653955ac521e5a0fe26e51abe5111b 100644 (file)
@@ -184,6 +184,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_sysconfdir}/ctdb/events.d/70.iscsi
 %{_sysconfdir}/ctdb/events.d/91.lvs
 %{_sysconfdir}/ctdb/events.d/99.timeout
+%config(noreplace) %{_sysconfdir}/ctdb/nfs-checks.d/00.portmapper.check
 %config(noreplace) %{_sysconfdir}/ctdb/nfs-checks.d/10.status.check
 %config(noreplace) %{_sysconfdir}/ctdb/nfs-checks.d/20.nfs.check
 %config(noreplace) %{_sysconfdir}/ctdb/nfs-checks.d/20.nfs_ganesha.disabled
diff --git a/ctdb/tests/eventscripts/60.nfs.monitor.106.sh b/ctdb/tests/eventscripts/60.nfs.monitor.106.sh
new file mode 100755 (executable)
index 0000000..49329c3
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "portmapper down, 2 iterations"
+
+setup_nfs
+rpc_services_down "portmapper"
+
+nfs_iterate_test 2 "portmapper"
index 8ac6894e6efa19f270ffc365c5172e2606e51ee7..46a5281d425e66184d4344959e79c440f58b4c33 100644 (file)
@@ -803,7 +803,8 @@ setup_nfs ()
 
        export CTDB_MANAGED_SERVICES="foo nfs bar"
 
-       rpc_services_up "nfs" "mountd" "rquotad" "nlockmgr" "status"
+       rpc_services_up \
+           "portmapper" "nfs" "mountd" "rquotad" "nlockmgr" "status"
 
        nfs_setup_fake_threads "nfsd"
        nfs_setup_fake_threads "rpc.foobar"  # Just set the variable to empty
@@ -850,11 +851,12 @@ rpc_services_up ()
     for _i ; do
        debug "Marking RPC service \"${_i}\" as available"
        case "$_i" in
-           nfs)      _t="2:3" ;;
-           mountd)   _t="1:3" ;;
-           rquotad)  _t="1:2" ;;
-           nlockmgr) _t="3:4" ;;
-           status)   _t="1:1" ;;
+           portmapper) _t="2:4" ;;
+           nfs)        _t="2:3" ;;
+           mountd)     _t="1:3" ;;
+           rquotad)    _t="1:2" ;;
+           nlockmgr)   _t="3:4" ;;
+           status)     _t="1:1" ;;
            *) die "Internal error - unsupported RPC service \"${_i}\"" ;;
        esac
 
@@ -975,17 +977,20 @@ rpc_set_service_failure_response ()
        # Don't bother syntax checking, eventscript does that...
        . "$_file"
 
-       # Just use the first version, default to 1.  This is dumb but
+       # Just use the first version, or use default.  This is dumb but
        # handles all the cases that we care about now...
        if [ -n "$version" ] ; then
            _ver="${version%% *}"
        else
-           _ver=1
+           case "$_rpc_service" in
+               portmapper) _ver="" ;;
+               *)          _ver=1  ;;
+           esac
        fi
        _rpc_check_out="\
 $_rpc_service failed RPC check:
 rpcinfo: RPC: Program not registered
-program $_rpc_service version $_ver is not available"
+program $_rpc_service${_ver:+ version }${_ver} is not available"
 
        if [ $unhealthy_after -gt 0 -a $_numfails -ge $unhealthy_after ] ; then
            _unhealthy=true