12a457
From 241d76a1b8440aace86020f63c50f852833ca77f Mon Sep 17 00:00:00 2001
12a457
From: Kaleb S KEITHLEY <kkeithle@redhat.com>
12a457
Date: Tue, 26 Apr 2016 10:53:33 -0400
12a457
Subject: [PATCH 097/104] common-ha: continuous grace_mon log messages in /var/log/messages
12a457
12a457
messages are seen on RHEL6.x and RHEL7.1 and earlier versions of
12a457
pacemaker. (And RHEL7.2 with RHEL7.1 pacemaker packages.)
12a457
12a457
It's not possible to query attrd attributes in the older version,
12a457
only set/update/clear them. The messages come from invalid attempts
12a457
to query the attributes.
12a457
12a457
However it is possible to query crm attributes. The fix here is to
12a457
create a "shadow" crm attribute for the attrd attribute. Changes are
12a457
made to both, queries are made on the crm attribute.
12a457
12a457
(Resource Agents "follow" the attrd attribute using constraint locations,
12a457
so we must keep the attrd attribute.)
12a457
12a457
Backport of
12a457
>> master:
12a457
>> Change-Id: I84ac1a80673e528d98b67b7d5062e21dcf744d4a
12a457
>> BUG: 1324509
12a457
>> http://review.gluster.org/#/c/13919/
12a457
12a457
> release-3.7
12a457
> Change-Id: I7301c48849496be026ef598c588e78c68f273a8a
12a457
> BUG: 1324510
12a457
> http://review.gluster.org/#/c/13920/
12a457
12a457
Change-Id: Id6c0ee018086f43f3f0ea3b8d1c30595c50453ac
12a457
BUG: 1321556
12a457
Signed-off-by: Kaleb S KEITHLEY <kkeithle@redhat.com>
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/73056
12a457
Reviewed-by: Jiffin Thottan <jthottan@redhat.com>
12a457
Reviewed-by: Soumya Koduri <skoduri@redhat.com>
12a457
Tested-by: Soumya Koduri <skoduri@redhat.com>
12a457
---
12a457
 extras/ganesha/ocf/ganesha_grace     |   28 ++++++++++++++----------
12a457
 extras/ganesha/ocf/ganesha_mon       |   39 +++++++++++++++++++++------------
12a457
 extras/ganesha/ocf/ganesha_nfsd      |   12 +++++-----
12a457
 extras/ganesha/scripts/ganesha-ha.sh |    2 +-
12a457
 4 files changed, 48 insertions(+), 33 deletions(-)
12a457
12a457
diff --git a/extras/ganesha/ocf/ganesha_grace b/extras/ganesha/ocf/ganesha_grace
12a457
index a82c9af..7c629f5 100644
12a457
--- a/extras/ganesha/ocf/ganesha_grace
12a457
+++ b/extras/ganesha/ocf/ganesha_grace
12a457
@@ -30,17 +30,17 @@
12a457
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
12a457
 
12a457
 if [ -n "$OCF_DEBUG_LIBRARY" ]; then
12a457
-    . $OCF_DEBUG_LIBRARY
12a457
+	. $OCF_DEBUG_LIBRARY
12a457
 else
12a457
-    : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
12a457
-. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
12a457
+	: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
12a457
+	. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
12a457
 fi
12a457
 
12a457
 OCF_RESKEY_grace_active_default="grace-active"
12a457
 : ${OCF_RESKEY_grace_active=${OCF_RESKEY_grace_active_default}}
12a457
 
12a457
 ganesha_meta_data() {
12a457
-        cat <
12a457
+	cat <
12a457
 
12a457
 
12a457
 <resource-agent name="ganesha_grace">
12a457
@@ -93,9 +93,11 @@ esac
12a457
 
12a457
 ganesha_grace_start()
12a457
 {
12a457
-        rc=${OCF_ERR_GENERIC}
12a457
+	local rc=${OCF_ERR_GENERIC}
12a457
+	local short_host=$(hostname -s)
12a457
+
12a457
 	ocf_log debug "ganesha_grace_start()"
12a457
-	attr=$(attrd_updater -Q -n ${OCF_RESKEY_grace_active})
12a457
+	attr=$(crm_attribute --query --node=${short_host} --name=${OCF_RESKEY_grace_active})
12a457
 
12a457
 	# Three possibilities:
12a457
 	# 1. There is no attribute at all and attr_updater returns
12a457
@@ -116,7 +118,7 @@ ganesha_grace_start()
12a457
 	fi
12a457
 
12a457
 	# case 2
12a457
-	if [[ "${attr}" = *"value=\"1\"" ]]; then
12a457
+	if [[ "${attr}" = *"value=1" ]]; then
12a457
 		return ${OCF_SUCCESS}
12a457
 	fi
12a457
 
12a457
@@ -149,10 +151,12 @@ ganesha_grace_notify()
12a457
 
12a457
 ganesha_grace_monitor()
12a457
 {
12a457
-        rc=${OCF_ERR_GENERIC}
12a457
+	local rc=${OCF_ERR_GENERIC}
12a457
+	local short_host=$(hostname -s)
12a457
+
12a457
 	ocf_log debug "monitor"
12a457
 
12a457
-	attr=$(attrd_updater -Q -n ${OCF_RESKEY_grace_active})
12a457
+	attr=$(crm_attribute --query --node=${short_host} --name=${OCF_RESKEY_grace_active})
12a457
 
12a457
 	# if there is no attribute (yet), maybe it's because
12a457
 	# this RA started before ganesha_mon (nfs-mon) has had
12a457
@@ -162,7 +166,7 @@ ganesha_grace_monitor()
12a457
 		return ${OCF_SUCCESS}
12a457
 	fi
12a457
 
12a457
-	if [[ "${attr}" = *"value=\"1\"" ]]; then
12a457
+	if [[ "${attr}" = *"value=1" ]]; then
12a457
 		rc=${OCF_SUCCESS}
12a457
 	fi
12a457
 
12a457
@@ -187,8 +191,8 @@ status|monitor) ganesha_grace_monitor
12a457
 notify)         ganesha_grace_notify
12a457
 		;;
12a457
 *)              ganesha_grace_usage
12a457
-                exit ${OCF_ERR_UNIMPLEMENTED}
12a457
-                ;;
12a457
+		exit ${OCF_ERR_UNIMPLEMENTED}
12a457
+		;;
12a457
 esac
12a457
 
12a457
 rc=$?
12a457
diff --git a/extras/ganesha/ocf/ganesha_mon b/extras/ganesha/ocf/ganesha_mon
12a457
index f55cf7f..65450b8 100644
12a457
--- a/extras/ganesha/ocf/ganesha_mon
12a457
+++ b/extras/ganesha/ocf/ganesha_mon
12a457
@@ -30,10 +30,10 @@
12a457
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
12a457
 
12a457
 if [ -n "${OCF_DEBUG_LIBRARY}" ]; then
12a457
-    . ${OCF_DEBUG_LIBRARY}
12a457
+	. ${OCF_DEBUG_LIBRARY}
12a457
 else
12a457
-    : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
12a457
-. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
12a457
+	: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
12a457
+	. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
12a457
 fi
12a457
 
12a457
 # Defaults
12a457
@@ -46,7 +46,7 @@ OCF_RESKEY_grace_delay_default="5"
12a457
 : ${OCF_RESKEY_grace_delay=${OCF_RESKEY_grace_delay_default}}
12a457
 
12a457
 ganesha_meta_data() {
12a457
-        cat <
12a457
+	cat <
12a457
 
12a457
 
12a457
 <resource-agent name="ganesha_mon">
12a457
@@ -113,13 +113,13 @@ ganesha_mon_start()
12a457
 {
12a457
 	ocf_log debug "ganesha_mon_start"
12a457
 	ganesha_mon_monitor
12a457
-        return $OCF_SUCCESS
12a457
+	return $OCF_SUCCESS
12a457
 }
12a457
 
12a457
 ganesha_mon_stop()
12a457
 {
12a457
 	ocf_log debug "ganesha_mon_stop"
12a457
-        return $OCF_SUCCESS
12a457
+	return $OCF_SUCCESS
12a457
 }
12a457
 
12a457
 ganesha_mon_monitor()
12a457
@@ -142,11 +142,22 @@ ganesha_mon_monitor()
12a457
 			ocf_log info "warning: attrd_updater -n ${OCF_RESKEY_ganesha_active} -v 1 failed"
12a457
 		fi
12a457
 
12a457
+		# ganesha_grace (nfs-grace) RA follows grace-active attr
12a457
+		# w/ constraint location
12a457
 		attrd_updater -n ${OCF_RESKEY_grace_active} -v 1
12a457
 		if [ $? -ne 0 ]; then
12a457
 			ocf_log info "warning: attrd_updater -n ${OCF_RESKEY_grace_active} -v 1 failed"
12a457
 		fi
12a457
 
12a457
+		# ganesha_mon (nfs-mon) and ganesha_grace (nfs-grace)
12a457
+		# track grace-active crm_attr (attr != crm_attr)
12a457
+		# we can't just use the attr as there's no way to query
12a457
+		# its value in RHEL6 pacemaker
12a457
+		crm_attribute --node=${short_host} --lifetime=forever --name=${OCF_RESKEY_grace_active} --update=1
12a457
+		if [ $? -ne 0 ]; then
12a457
+			ocf_log info "warning: crm_attribute --node=${short_host} --lifetime=forever --name=${OCF_RESKEY_grace_active} --update=1 failed"
12a457
+		fi
12a457
+
12a457
 		return ${OCF_SUCCESS}
12a457
 	fi
12a457
 
12a457
@@ -155,23 +166,23 @@ ganesha_mon_monitor()
12a457
 	#
12a457
 	# Meanwhile the ganesha_grace notify() runs when its
12a457
 	# nfs-grace resource is disabled on a node; which
12a457
-	# is triggered by clearing the ganesha-grace node
12a457
-	# attribute on this node.
12a457
+	# is triggered by clearing the grace-active attribute
12a457
+	# on this node.
12a457
 	#
12a457
 	# We need to allow time for it to run and put
12a457
 	# the remaining ganesha.nfsds into grace before
12a457
 	# initiating the VIP fail-over.
12a457
 
12a457
+	sleep ${OCF_RESKEY_grace_delay}
12a457
+
12a457
 	attrd_updater -D -n ${OCF_RESKEY_grace_active}
12a457
 	if [ $? -ne 0 ]; then
12a457
 		ocf_log info "warning: attrd_updater -D -n ${OCF_RESKEY_grace_active} failed"
12a457
 	fi
12a457
 
12a457
-	sleep ${OCF_RESKEY_grace_delay}
12a457
-
12a457
-	attrd_updater -D -n ${OCF_RESKEY_ganesha_active}
12a457
+	crm_attribute --node=${short_host} --name=${OCF_RESKEY_grace_active} --update=0
12a457
 	if [ $? -ne 0 ]; then
12a457
-		ocf_log info "warning: attrd_updater -D -n ${OCF_RESKEY_ganesha_active} failed"
12a457
+		ocf_log info "warning: crm_attribute --node=${short_host} --name=${OCF_RESKEY_grace_active} --update=0 failed"
12a457
 	fi
12a457
 
12a457
 	return ${OCF_SUCCESS}
12a457
@@ -193,8 +204,8 @@ stop)           ganesha_mon_stop
12a457
 status|monitor) ganesha_mon_monitor
12a457
 		;;
12a457
 *)              ganesha_mon_usage
12a457
-                exit ${OCF_ERR_UNIMPLEMENTED}
12a457
-                ;;
12a457
+		exit ${OCF_ERR_UNIMPLEMENTED}
12a457
+		;;
12a457
 esac
12a457
 
12a457
 rc=$?
12a457
diff --git a/extras/ganesha/ocf/ganesha_nfsd b/extras/ganesha/ocf/ganesha_nfsd
12a457
index a9d3e4d..29e333c 100644
12a457
--- a/extras/ganesha/ocf/ganesha_nfsd
12a457
+++ b/extras/ganesha/ocf/ganesha_nfsd
12a457
@@ -30,17 +30,17 @@
12a457
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
12a457
 
12a457
 if [ -n "${OCF_DEBUG_LIBRARY}" ]; then
12a457
-    . ${OCF_DEBUG_LIBRARY}
12a457
+	. ${OCF_DEBUG_LIBRARY}
12a457
 else
12a457
-    : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
12a457
-. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
12a457
+	: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
12a457
+	. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
12a457
 fi
12a457
 
12a457
 OCF_RESKEY_ha_vol_mnt_default="/var/run/gluster/shared_storage"
12a457
 : ${OCF_RESKEY_ha_vol_mnt=${OCF_RESKEY_ha_vol_mnt_default}}
12a457
 
12a457
 ganesha_meta_data() {
12a457
-        cat <
12a457
+	cat <
12a457
 
12a457
 
12a457
 <resource-agent name="ganesha_nfsd">
12a457
@@ -156,8 +156,8 @@ stop)           ganesha_nfsd_stop
12a457
 status|monitor) ganesha_nfsd_monitor
12a457
 		;;
12a457
 *)              ganesha_nfsd_usage
12a457
-                exit ${OCF_ERR_UNIMPLEMENTED}
12a457
-                ;;
12a457
+		exit ${OCF_ERR_UNIMPLEMENTED}
12a457
+		;;
12a457
 esac
12a457
 
12a457
 rc=$?
12a457
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
12a457
index d866220..7f1ea4c 100644
12a457
--- a/extras/ganesha/scripts/ganesha-ha.sh
12a457
+++ b/extras/ganesha/scripts/ganesha-ha.sh
12a457
@@ -376,7 +376,7 @@ teardown_cluster()
12a457
         if [[ ${HA_CLUSTER_NODES} != *${server}* ]]; then
12a457
             logger "info: ${server} is not in config, removing"
12a457
 
12a457
-            pcs cluster stop ${server}
12a457
+            pcs cluster stop ${server} --force
12a457
             if [ $? -ne 0 ]; then
12a457
                 logger "warning: pcs cluster stop ${server} failed"
12a457
             fi
12a457
-- 
12a457
1.7.1
12a457