Blob Blame History Raw
From bf7d9cb56b80314a8c936ae01d2d755aefa93e16 Mon Sep 17 00:00:00 2001
From: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Date: Tue, 16 Jun 2015 10:07:48 -0400
Subject: [PATCH 115/129] common-ha: cluster setup issues on RHEL7

 * use --name on RHEL7 (later versions of pcs drop --name) we guessed
   wrong and did not get the version that dropped use of --name option
 * more robust config file param parsing for n/v with ""s in the value
   after not sourcing the config file
 * pid file fix. RHEL6 init.d adds -p /var/run/ganesha.nfsd.pid to
   cmdline options. RHEL7 systemd does not, so defaults to
   /var/run/ganesha.pid.

> backport of
>> Change-Id: I575aa13c98f05523cca10c55f2c387200bad3f93
>> BUG: 1229948
>> Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
>> http://review.gluster.org/#/c/11257/
>
> Change-Id: I2236d41c8a87e4ead082274dddec19307d1f4db9
> BUG: 1232333
> Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
> http://review.gluster.org/#/c/11258/

Change-Id: Ib0245c6e1242524af2a8d8bc3b204fe892304fcc
BUG: 1229601
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/50841
Reviewed-by: Soumya Koduri <skoduri@redhat.com>
---
 extras/ganesha/ocf/ganesha_grace     |   12 ++++++++++--
 extras/ganesha/ocf/ganesha_mon       |   12 ++++++++++--
 extras/ganesha/scripts/ganesha-ha.sh |   23 ++++++++++++++---------
 3 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/extras/ganesha/ocf/ganesha_grace b/extras/ganesha/ocf/ganesha_grace
index dceaccf..75ec16c 100644
--- a/extras/ganesha/ocf/ganesha_grace
+++ b/extras/ganesha/ocf/ganesha_grace
@@ -88,14 +88,22 @@ ganesha_grace_start()
 	local resourcename=""
 	local deadserver=""
 	local tmpIFS=${IFS}
+	local pid_file="/var/run/ganesha.nfsd.pid"
+
+	# RHEL6 /etc/init.d/nfs-ganesha adds "-p /var/run/ganesha.nfsd.pid"
+	# RHEL7 systemd does not. Would be nicer if all distros used the
+	# same pid file.
+	if [ -e /usr/lib/systemd/system/nfs-ganesha.service ]; then
+		pid_file="/var/run/ganesha.pid"
+	fi
 
 	# logger "ganesha_grace_start()"
 	# we're here because somewhere in the cluster one or more
 	# of the ganesha.nfsds have died, triggering a floating IP
 	# address to move. Resource constraint location rules ensure
 	# that this is invoked before the floating IP is moved.
-	if [ -e /var/run/ganesha.nfsd.pid -a \
-	     -d /proc/$(cat /var/run/ganesha.nfsd.pid) ]; then
+	if [ -e ${pid_file} -a \
+	     -d /proc/$(cat ${pid_file} ) ]; then
 		# my ganesha.nfsd is still running
 		# find out which one died?
 
diff --git a/extras/ganesha/ocf/ganesha_mon b/extras/ganesha/ocf/ganesha_mon
index 47943f8..c8e7de9 100644
--- a/extras/ganesha/ocf/ganesha_mon
+++ b/extras/ganesha/ocf/ganesha_mon
@@ -97,9 +97,17 @@ ganesha_mon_stop()
 ganesha_mon_monitor()
 {
 	local short_host=$(hostname -s)
+	local pid_file="/var/run/ganesha.nfsd.pid"
 
-	if [ -e /var/run/ganesha.nfsd.pid -a \
-	     -d /proc/$(cat /var/run/ganesha.nfsd.pid) ]; then
+	# RHEL6 /etc/init.d/nfs-ganesha adds -p /var/run/ganesha.nfsd.pid
+	# RHEL7 systemd does not. Would be nice if all distros used the
+	# same pid file.
+	if [ -e /usr/lib/systemd/system/nfs-ganesha.service ]; then
+		pid_file="/var/run/ganesha.pid"
+	fi
+
+	if [ -e ${pid_file} -a \
+	     -d /proc/$(cat ${pid_file} ) ]; then
 		( pcs resource delete ${short_host}-dead_ip-1 > /dev/null 2>&1 )
 
 		attrd_updater -n ganesha-active -v 1
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
index fc2a009..725b6b4 100755
--- a/extras/ganesha/scripts/ganesha-ha.sh
+++ b/extras/ganesha/scripts/ganesha-ha.sh
@@ -26,7 +26,9 @@ HA_CONFDIR=""
 HA_VOL_NAME="gluster_shared_storage"
 HA_VOL_MNT="/var/run/gluster/shared_storage"
 SERVICE_MAN="DISTRO_NOT_FOUND"
-CONF=$(cat /etc/sysconfig/ganesha | grep "CONFFILE" | cut -f 2 -d "=")
+cfgline=$(grep ^CONFFILE= /etc/sysconfig/ganesha)
+eval $(echo ${cfgline} | grep -F CONFFILE=)
+GANESHA_CONF=${CONFFILE:-/etc/ganesha/ganesha.conf}
 
 RHEL6_PCS_CNAME_OPTION="--name"
 
@@ -236,7 +238,7 @@ cleanup_ganesha_config ()
        rm -rf ${HA_CONFDIR}/.export_added
        rm -rf /etc/cluster/cluster.conf*
        rm -rf /var/lib/pacemaker/cib/*
-       sed -r -i -e '/^%include[[:space:]]+".+\.conf"$/d' $CONF
+       sed -r -i -e '/^%include[[:space:]]+".+\.conf"$/d' ${GANESHA_CONF}
 }
 
 do_create_virt_ip_constraints()
@@ -740,15 +742,18 @@ main()
     local node=""
     local vip=""
 
-    ha_name=$(grep ^HA_NAME= ${ha_conf} | cut -d = -f 2)
-    HA_NAME=${ha_name//\"/}
-    ha_vol_server=$(grep ^HA_VOL_SERVER= ${ha_conf} | cut -d = -f 2)
-    HA_VOL_SERVER=${ha_vol_server//\"/}
-    ha_cluster_nodes=$(grep ^HA_CLUSTER_NODES= ${ha_conf} | cut -d = -f 2)
-    HA_CLUSTER_NODES=${ha_cluster_nodes//\"/}
+    # ignore any comment lines
+    cfgline=$(grep ^HA_NAME= ${ha_conf})
+    eval $(echo ${cfgline} | grep -F HA_NAME=)
+    cfgline=$(grep ^HA_VOL_SERVER= ${ha_conf})
+    eval $(echo ${cfgline} | grep -F HA_VOL_SERVER=)
+    cfgline=$(grep ^HA_CLUSTER_NODES= ${ha_conf})
+    eval $(echo ${cfgline} | grep -F HA_CLUSTER_NODES=)
 
+    # we'll pretend that nobody ever edits /etc/os-release
     if [ -e /etc/os-release ]; then
-        RHEL6_PCS_CNAME_OPTION=""
+        eval $(grep -F "REDHAT_SUPPORT_PRODUCT=" /etc/os-release)
+        [ "$REDHAT_SUPPORT_PRODUCT" == "Fedora" ] && RHEL6_PCS_CNAME_OPTION=""
     fi
 
     case "${cmd}" in
-- 
1.7.1