I had some problems with the monitor operation of the ocf:heartbeat:exportfs
resource. I have a solution for one of them that I'd to share with the 
community.

The first comes from using regex-like expressions for clientspec; e.g.,

primitive ExportUsrNevis ocf:heartbeat:exportfs \
        op monitor interval="30" timeout="20" \
        params clientspec="*.nevis.columbia.edu" \
        directory="/usr/nevis" fsid="20"

For my version of nfs-utils (1.2.3), expressions like "*.nevis.columbia.edu" are
allowed. The problem is that the monitor operation will fail, since the exportfs
resource uses grep to test the result of the exportfs command:

exportfs | grep -zqs 
"${OCF_RESKEY_directory}[[:space:]]*${OCF_RESKEY_clientspec}"

I've attached a text file with my proposed change. It "escapes" any regex
characters in clientspec.

I had another problem for which I don't think there's a simple overall solution:
if clientspec refers to a host alias. For example:

# host mail
mail.nevis.columbia.edu is an alias for franklin.nevis.columbia.edu.
franklin.nevis.columbia.edu has address 129.236.252.8

crm configure primitive ExportMail ocf:heartbeat:exportfs \
        params clientspec="mail" directory="/mail" fsid="30"

# exportfs
/mail           franklin.nevis.columbia.edu

The exportfs command "canonicalizes" the clientspec, so once again the monitor
operation will always fail.

I either have to use the canonical name in the clientspec, or omit the monitor
operation. I tried to come up with simple code to get the canonical name in
bash, but it gets tricky to determine both when canonicalization is needed, and
how to extract it from the output of the "host" command in an OS-independent 
way.
-- 
Bill Seligman             | Phone: (914) 591-2823
Nevis Labs, Columbia Univ | mailto://[email protected]
PO Box 137                |
Irvington NY 10533 USA    | http://www.nevis.columbia.edu/~seligman/
# diff -u exportfs.ori /usr/lib/ocf/resource.d/heartbeat/exportfs
--- exportfs.ori        2012-02-17 18:31:59.518848166 -0500
+++ /usr/lib/ocf/resource.d/heartbeat/exportfs  2012-02-20 18:14:56.254199732 
-0500
@@ -181,9 +181,11 @@
 
 exportfs_monitor ()
 {
+        # Just in case the clientspec contains regexp characters
+        CLIENTSPEC=`echo "${OCF_RESKEY_clientspec}" | sed -e 
"s/[\*\?\[\[]/\\\\\&/g"`
        # "grep -z" matches across newlines, which is necessary as
        # exportfs output wraps lines for long export directory names
-       exportfs | grep -zqs 
"${OCF_RESKEY_directory}[[:space:]]*${OCF_RESKEY_clientspec}"
+       exportfs | grep -zqs "${OCF_RESKEY_directory}[[:space:]]*${CLIENTSPEC}"
 
 #Adapt grep status code to OCF return code
        case $? in
@@ -224,7 +226,7 @@
        fi
        OPTIONS="-o ${OPTIONS}"
 
-       ocf_run exportfs -v ${OPTIONS} 
${OCF_RESKEY_clientspec}:${OCF_RESKEY_directory} || exit $OCF_ERR_GENERIC
+       ocf_run exportfs -v ${OPTIONS} 
"${OCF_RESKEY_clientspec}":${OCF_RESKEY_directory} || exit $OCF_ERR_GENERIC
 
        # Restore the rmtab to ensure smooth NFS-over-TCP failover
        restore_rmtab
@@ -246,7 +248,7 @@
        # Backup the rmtab to ensure smooth NFS-over-TCP failover
        backup_rmtab
 
-       ocf_run exportfs -v -u ${OCF_RESKEY_clientspec}:${OCF_RESKEY_directory}
+       ocf_run exportfs -v -u 
"${OCF_RESKEY_clientspec}":${OCF_RESKEY_directory}
        rc=$?
 
        if ocf_is_true ${OCF_RESKEY_unlock_on_stop}; then

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems

Reply via email to