cb8e9e
From bf7d9cb56b80314a8c936ae01d2d755aefa93e16 Mon Sep 17 00:00:00 2001
cb8e9e
From: Kaleb S. KEITHLEY <kkeithle@redhat.com>
cb8e9e
Date: Tue, 16 Jun 2015 10:07:48 -0400
cb8e9e
Subject: [PATCH 115/129] common-ha: cluster setup issues on RHEL7
cb8e9e
cb8e9e
 * use --name on RHEL7 (later versions of pcs drop --name) we guessed
cb8e9e
   wrong and did not get the version that dropped use of --name option
cb8e9e
 * more robust config file param parsing for n/v with ""s in the value
cb8e9e
   after not sourcing the config file
cb8e9e
 * pid file fix. RHEL6 init.d adds -p /var/run/ganesha.nfsd.pid to
cb8e9e
   cmdline options. RHEL7 systemd does not, so defaults to
cb8e9e
   /var/run/ganesha.pid.
cb8e9e
cb8e9e
> backport of
cb8e9e
>> Change-Id: I575aa13c98f05523cca10c55f2c387200bad3f93
cb8e9e
>> BUG: 1229948
cb8e9e
>> Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
cb8e9e
>> http://review.gluster.org/#/c/11257/
cb8e9e
>
cb8e9e
> Change-Id: I2236d41c8a87e4ead082274dddec19307d1f4db9
cb8e9e
> BUG: 1232333
cb8e9e
> Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
cb8e9e
> http://review.gluster.org/#/c/11258/
cb8e9e
cb8e9e
Change-Id: Ib0245c6e1242524af2a8d8bc3b204fe892304fcc
cb8e9e
BUG: 1229601
cb8e9e
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/50841
cb8e9e
Reviewed-by: Soumya Koduri <skoduri@redhat.com>
cb8e9e
---
cb8e9e
 extras/ganesha/ocf/ganesha_grace     |   12 ++++++++++--
cb8e9e
 extras/ganesha/ocf/ganesha_mon       |   12 ++++++++++--
cb8e9e
 extras/ganesha/scripts/ganesha-ha.sh |   23 ++++++++++++++---------
cb8e9e
 3 files changed, 34 insertions(+), 13 deletions(-)
cb8e9e
cb8e9e
diff --git a/extras/ganesha/ocf/ganesha_grace b/extras/ganesha/ocf/ganesha_grace
cb8e9e
index dceaccf..75ec16c 100644
cb8e9e
--- a/extras/ganesha/ocf/ganesha_grace
cb8e9e
+++ b/extras/ganesha/ocf/ganesha_grace
cb8e9e
@@ -88,14 +88,22 @@ ganesha_grace_start()
cb8e9e
 	local resourcename=""
cb8e9e
 	local deadserver=""
cb8e9e
 	local tmpIFS=${IFS}
cb8e9e
+	local pid_file="/var/run/ganesha.nfsd.pid"
cb8e9e
+
cb8e9e
+	# RHEL6 /etc/init.d/nfs-ganesha adds "-p /var/run/ganesha.nfsd.pid"
cb8e9e
+	# RHEL7 systemd does not. Would be nicer if all distros used the
cb8e9e
+	# same pid file.
cb8e9e
+	if [ -e /usr/lib/systemd/system/nfs-ganesha.service ]; then
cb8e9e
+		pid_file="/var/run/ganesha.pid"
cb8e9e
+	fi
cb8e9e
 
cb8e9e
 	# logger "ganesha_grace_start()"
cb8e9e
 	# we're here because somewhere in the cluster one or more
cb8e9e
 	# of the ganesha.nfsds have died, triggering a floating IP
cb8e9e
 	# address to move. Resource constraint location rules ensure
cb8e9e
 	# that this is invoked before the floating IP is moved.
cb8e9e
-	if [ -e /var/run/ganesha.nfsd.pid -a \
cb8e9e
-	     -d /proc/$(cat /var/run/ganesha.nfsd.pid) ]; then
cb8e9e
+	if [ -e ${pid_file} -a \
cb8e9e
+	     -d /proc/$(cat ${pid_file} ) ]; then
cb8e9e
 		# my ganesha.nfsd is still running
cb8e9e
 		# find out which one died?
cb8e9e
 
cb8e9e
diff --git a/extras/ganesha/ocf/ganesha_mon b/extras/ganesha/ocf/ganesha_mon
cb8e9e
index 47943f8..c8e7de9 100644
cb8e9e
--- a/extras/ganesha/ocf/ganesha_mon
cb8e9e
+++ b/extras/ganesha/ocf/ganesha_mon
cb8e9e
@@ -97,9 +97,17 @@ ganesha_mon_stop()
cb8e9e
 ganesha_mon_monitor()
cb8e9e
 {
cb8e9e
 	local short_host=$(hostname -s)
cb8e9e
+	local pid_file="/var/run/ganesha.nfsd.pid"
cb8e9e
 
cb8e9e
-	if [ -e /var/run/ganesha.nfsd.pid -a \
cb8e9e
-	     -d /proc/$(cat /var/run/ganesha.nfsd.pid) ]; then
cb8e9e
+	# RHEL6 /etc/init.d/nfs-ganesha adds -p /var/run/ganesha.nfsd.pid
cb8e9e
+	# RHEL7 systemd does not. Would be nice if all distros used the
cb8e9e
+	# same pid file.
cb8e9e
+	if [ -e /usr/lib/systemd/system/nfs-ganesha.service ]; then
cb8e9e
+		pid_file="/var/run/ganesha.pid"
cb8e9e
+	fi
cb8e9e
+
cb8e9e
+	if [ -e ${pid_file} -a \
cb8e9e
+	     -d /proc/$(cat ${pid_file} ) ]; then
cb8e9e
 		( pcs resource delete ${short_host}-dead_ip-1 > /dev/null 2>&1 )
cb8e9e
 
cb8e9e
 		attrd_updater -n ganesha-active -v 1
cb8e9e
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
cb8e9e
index fc2a009..725b6b4 100755
cb8e9e
--- a/extras/ganesha/scripts/ganesha-ha.sh
cb8e9e
+++ b/extras/ganesha/scripts/ganesha-ha.sh
cb8e9e
@@ -26,7 +26,9 @@ HA_CONFDIR=""
cb8e9e
 HA_VOL_NAME="gluster_shared_storage"
cb8e9e
 HA_VOL_MNT="/var/run/gluster/shared_storage"
cb8e9e
 SERVICE_MAN="DISTRO_NOT_FOUND"
cb8e9e
-CONF=$(cat /etc/sysconfig/ganesha | grep "CONFFILE" | cut -f 2 -d "=")
cb8e9e
+cfgline=$(grep ^CONFFILE= /etc/sysconfig/ganesha)
cb8e9e
+eval $(echo ${cfgline} | grep -F CONFFILE=)
cb8e9e
+GANESHA_CONF=${CONFFILE:-/etc/ganesha/ganesha.conf}
cb8e9e
 
cb8e9e
 RHEL6_PCS_CNAME_OPTION="--name"
cb8e9e
 
cb8e9e
@@ -236,7 +238,7 @@ cleanup_ganesha_config ()
cb8e9e
        rm -rf ${HA_CONFDIR}/.export_added
cb8e9e
        rm -rf /etc/cluster/cluster.conf*
cb8e9e
        rm -rf /var/lib/pacemaker/cib/*
cb8e9e
-       sed -r -i -e '/^%include[[:space:]]+".+\.conf"$/d' $CONF
cb8e9e
+       sed -r -i -e '/^%include[[:space:]]+".+\.conf"$/d' ${GANESHA_CONF}
cb8e9e
 }
cb8e9e
 
cb8e9e
 do_create_virt_ip_constraints()
cb8e9e
@@ -740,15 +742,18 @@ main()
cb8e9e
     local node=""
cb8e9e
     local vip=""
cb8e9e
 
cb8e9e
-    ha_name=$(grep ^HA_NAME= ${ha_conf} | cut -d = -f 2)
cb8e9e
-    HA_NAME=${ha_name//\"/}
cb8e9e
-    ha_vol_server=$(grep ^HA_VOL_SERVER= ${ha_conf} | cut -d = -f 2)
cb8e9e
-    HA_VOL_SERVER=${ha_vol_server//\"/}
cb8e9e
-    ha_cluster_nodes=$(grep ^HA_CLUSTER_NODES= ${ha_conf} | cut -d = -f 2)
cb8e9e
-    HA_CLUSTER_NODES=${ha_cluster_nodes//\"/}
cb8e9e
+    # ignore any comment lines
cb8e9e
+    cfgline=$(grep ^HA_NAME= ${ha_conf})
cb8e9e
+    eval $(echo ${cfgline} | grep -F HA_NAME=)
cb8e9e
+    cfgline=$(grep ^HA_VOL_SERVER= ${ha_conf})
cb8e9e
+    eval $(echo ${cfgline} | grep -F HA_VOL_SERVER=)
cb8e9e
+    cfgline=$(grep ^HA_CLUSTER_NODES= ${ha_conf})
cb8e9e
+    eval $(echo ${cfgline} | grep -F HA_CLUSTER_NODES=)
cb8e9e
 
cb8e9e
+    # we'll pretend that nobody ever edits /etc/os-release
cb8e9e
     if [ -e /etc/os-release ]; then
cb8e9e
-        RHEL6_PCS_CNAME_OPTION=""
cb8e9e
+        eval $(grep -F "REDHAT_SUPPORT_PRODUCT=" /etc/os-release)
cb8e9e
+        [ "$REDHAT_SUPPORT_PRODUCT" == "Fedora" ] && RHEL6_PCS_CNAME_OPTION=""
cb8e9e
     fi
cb8e9e
 
cb8e9e
     case "${cmd}" in
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e