This is the mail archive of the
cluster-cvs@sourceware.org
mailing list for the cluster.
RHEL5 - rgmanager: Resolve hostnames->IPs and back when checking NFSclients
- From: Lon Hohberger <lon at fedoraproject dot org>
- To: cluster-cvs-relay at redhat dot com
- Date: Tue, 16 Sep 2008 15:00:45 +0000 (UTC)
- Subject: RHEL5 - rgmanager: Resolve hostnames->IPs and back when checking NFSclients
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=deaedf0297919d3cbb29e1640219462f5850202b
Commit: deaedf0297919d3cbb29e1640219462f5850202b
Parent: 4b33d439abef45a120c1a4f471fadea9978ef086
Author: Lon Hohberger <lhh@redhat.com>
AuthorDate: Tue Sep 16 10:59:47 2008 -0400
Committer: Lon Hohberger <lhh@redhat.com>
CommitterDate: Tue Sep 16 11:00:26 2008 -0400
rgmanager: Resolve hostnames->IPs and back when checking NFS clients
Also enable caching for improved performance in services
with lots (hundreds) of individual mounters
Bugzillas #246668 & #455324
---
rgmanager/src/resources/nfsclient.sh | 93 ++++++++++++++++++++++++++++++++-
rgmanager/src/resources/service.sh | 21 ++++++++
2 files changed, 111 insertions(+), 3 deletions(-)
diff --git a/rgmanager/src/resources/nfsclient.sh b/rgmanager/src/resources/nfsclient.sh
index 8abac13..e4267aa 100755
--- a/rgmanager/src/resources/nfsclient.sh
+++ b/rgmanager/src/resources/nfsclient.sh
@@ -119,6 +119,38 @@ meta_data()
<content type="boolean"/>
</parameter>
+ <parameter name="service_name" inherit="service%name">
+ <longdesc lang="en">
+ Service this NFS export belongs to. Used for caching
+ exports on a per-service basis.
+ </longdesc>
+ <shortdesc lang="en">
+ Service Name
+ </shortdesc>
+ <content type="string"/>
+ </parameter>
+
+ <parameter name="use_cache" inherit="service%nfs_client_cache">
+ <longdesc lang="en">
+ On systems with large numbers of exports, a performance
+ problem in the exportfs command can cause inordinately long
+ status check times for services with lots of mounted
+ NFS clients. This occurs because exportfs does DNS queries
+ on all clients in the export list.
+
+ Setting this option to '1' will enable caching of the export
+ list returned from the exportfs command on a per-service
+ basis. The cache will last for 30 seconds before expiring
+ instead of being generated each time an nfsclient resource
+ is called.
+ </longdesc>
+ <shortdesc lang="en">
+ Enable exportfs list caching
+ </shortdesc>
+ <content type="integer"/>
+ </parameter>
+
+
</parameters>
<actions>
@@ -318,13 +350,68 @@ status|monitor)
#
export OCF_RESKEY_target_regexp=$(echo $OCF_RESKEY_target | \
sed -e 's/*/[*]/g' -e 's/?/[?]/g' -e 's/\./\\./g')
- exportfs -v | tr -d "\n" | sed -e 's/([^)]*)/\n/g' | grep -q \
- "^${OCF_RESKEY_path}[\t ]*.*${OCF_RESKEY_target_regexp}"
+ declare tmpfn
+ declare time_created time_now
+ declare -i delta=0
+
+ #
+ # Don't let anyone read the cache files.
+ #
+ umask 066
+ if [ -n "$OCF_RESKEY_service_name" ] && [ "$OCF_RESKEY_use_cache" = "1" ]; then
+
+ #
+ # For large #s of exports, we need to cache the information
+ #
+ tmpfn=/tmp/nfsclient-status-cache-$OCF_RESKEY_service_name
+
+ if [ -f "$tmpfn" ]; then
+ time_created=$(stat -c "%Y" $tmpfn)
+ time_now=$(date +"%s")
+ delta=$((time_now-time_created))
+ fi
+ #echo "Cache age = $delta seconds"
+ else
+ delta=100
+ #
+ # Create a different file if this is a separate instance
+ #
+ tmpfn=/tmp/nfsclient-status-cache-$$
+ fi
+
+ if ! [ -f "$tmpfn" ] || [ $delta -gt 30 ]; then
+ #echo "Create $tmpfn. Nonexistent / expired / no service name"
+ exportfs -v > $tmpfn
+ fi
+
+ cat $tmpfn | tr -d "\n" | sed -e 's/([^)]*)/\n/g' | grep -iq \
+ "^${OCF_RESKEY_path}[\t ]*.*${OCF_RESKEY_target_regexp}"
rv=$?
- if [ $rv -ne 0 ]; then
+
+ if [ $rv -eq 0 ]; then
+ [ -z "$OCF_RESKEY_service_name" ] && rm -f $tmpfn
+ exit 0
+ fi
+
+ declare OCF_RESKEY_target_tmp=$(clufindhostname -i "$OCF_RESKEY_target")
+ if [ $? -ne 0 ]; then
+ [ -z "$OCF_RESKEY_service_name" ] && rm -f $tmpfn
ocf_log err "nfsclient:$OCF_RESKEY_name is missing!"
+ exit 1
fi
+
+ cat $tmpfn | tr -d "\n" | sed -e 's/([^)]*)/\n/g' | grep -q \
+ "^${OCF_RESKEY_path}[\t ]*.*${OCF_RESKEY_target_tmp}"
+ rv=$?
+
+ [ -z "$OCF_RESKEY_service_name" ] && rm -f $tmpfn
+ if [ $rv -eq 0 ]; then
+ exit 0
+ fi
+
+ ocf_log err "nfsclient:$OCF_RESKEY_name is missing!"
+ exit 1
;;
recover)
diff --git a/rgmanager/src/resources/service.sh b/rgmanager/src/resources/service.sh
index 339657d..b7c9e08 100755
--- a/rgmanager/src/resources/service.sh
+++ b/rgmanager/src/resources/service.sh
@@ -127,6 +127,27 @@ meta_data()
</shortdesc>
<content type="boolean" default="0"/>
</parameter>
+
+ <parameter name="nfs_client_cache">
+ <longdesc lang="en">
+ On systems with large numbers of exports, a performance
+ problem in the exportfs command can cause inordinately long
+ status check times for services with lots of mounted
+ NFS clients. This occurs because exportfs does DNS queries
+ on all clients in the export list.
+
+ Setting this option to '1' will enable caching of the export
+ list returned from the exportfs command on a per-service
+ basis. The cache will last for 30 seconds before expiring
+ instead of being generated each time an nfsclient resource
+ is called.
+ </longdesc>
+ <shortdesc lang="en">
+ Enable exportfs list caching
+ </shortdesc>
+ <content type="integer" default="0"/>
+ </parameter>
+
<parameter name="recovery" reconfig="1">
<longdesc lang="en">