File fence-after-pacemaker-down.patch of Package drbd.1187

diff -Naur drbd-8.4.4.7.orig/scripts/crm-fence-peer.sh drbd-8.4.4.7/scripts/crm-fence-peer.sh
--- drbd-8.4.4.7.orig/scripts/crm-fence-peer.sh	2016-03-10 14:44:23.983968014 +0800
+++ drbd-8.4.4.7/scripts/crm-fence-peer.sh	2016-03-10 15:09:38.226865825 +0800
@@ -465,8 +465,10 @@
 	# For stonith-enabled=false, the "crmd" attribute may stay "online",
 	# but once ha="dead", we can stop waiting for changes.
 	ha_dead=false
-
-	for x in ${node_state%/>} ; do
+ 
+	node_state=${node_state%>}
+	node_state=${node_state%/}
+	for x in ${node_state} ; do
 		case $x in
 		in_ccm=\"*\")	x=${x#*=\"}; x=${x%\"}; in_ccm=$x ;;
 		crmd=\"*\")	x=${x#*=\"}; x=${x%\"}; crmd=$x ;;
@@ -500,6 +502,25 @@
 	[[ $crmd = "banned" ]] && will_fence=true
 	if [[ ${expected-down} = "down" && $in_ccm = "false"  && $crmd != "online" ]]; then
 		: "pacemaker considers this as clean down"
+	elif [[ $crmd/$join/$expected = "offline/down/down" ]] ; then
+		# Check if pacemaker is simply shutdown, but membership/quorum is
+		# possibly still established (corosync2/cman)
+		# 1.1.11 will set expected="down" on a clean shutdown too
+		# Look for "shutdown" transient node attribute
+		local node_attributes=$(set +x; echo "$cib_xml" |
+			awk "/<node_state [^\n]*uname=\"$DRBD_PEER\"/,/<\/instance_attributes>/"|
+			grep -F -e "<nvpair ")
+		if [ -n "${node_attributes}" ] ; then
+			local shut_down=$(set +x; echo "$node_attributes" |
+				awk '/ name="shutdown"/ {if (match($0, /value=\"([[:digit:]]+)\"/, values)) {print values[1]} }')
+			if [ -n "${shut_down}" ] ; then
+				: "pacemaker considers this as clean down"
+			else
+				will_fence=true
+			fi
+		else
+			will_fence=true
+		fi
 	elif [[ $in_ccm = false ]] || [[ $crmd != "online" ]]; then
 		will_fence=true
 	fi
openSUSE Build Service is sponsored by