Blame SOURCES/bz1200756-ipsrcaddr-misconfig.patch

261ad6
From 3c383f3dbb3b5351b25d33aa6e516ab8fc04a26a Mon Sep 17 00:00:00 2001
261ad6
From: David Vossel <dvossel@redhat.com>
261ad6
Date: Tue, 28 Apr 2015 11:47:21 -0500
261ad6
Subject: [PATCH] High: IPsrcaddr: return correct error code during stop when
261ad6
 misconfigured
261ad6
261ad6
---
261ad6
 heartbeat/IPsrcaddr | 45 +++++++++++++++++++++++++++++++--------------
261ad6
 1 file changed, 31 insertions(+), 14 deletions(-)
261ad6
261ad6
diff --git a/heartbeat/IPsrcaddr b/heartbeat/IPsrcaddr
261ad6
index 8163c0c..33c5be6 100755
261ad6
--- a/heartbeat/IPsrcaddr
261ad6
+++ b/heartbeat/IPsrcaddr
261ad6
@@ -387,15 +387,27 @@ ip_status() {
261ad6
 
261ad6
 srca_validate_all() {
261ad6
 
261ad6
-    check_binary $AWK
261ad6
-    check_binary $IFCONFIG
261ad6
+	if [ -z "$OCF_RESKEY_ipaddress" ]; then
261ad6
+		#  usage
261ad6
+		ocf_exit_reason "Please set OCF_RESKEY_ipaddress to the preferred source IP address!"
261ad6
+		return $OCF_ERR_CONFIGURED
261ad6
+	fi
261ad6
+
261ad6
+
261ad6
+	if ! [ "x$SYSTYPE" = "xLinux" ]; then
261ad6
+		# checks after this point are only relevant for linux.
261ad6
+		return $OCF_SUCCESS
261ad6
+	fi
261ad6
+
261ad6
+	check_binary $AWK
261ad6
+	check_binary $IFCONFIG
261ad6
 
261ad6
 #	The IP address should be in good shape
261ad6
 	if CheckIP "$ipaddress"; then
261ad6
 	  : 
261ad6
 	else
261ad6
 	  ocf_exit_reason "Invalid IP address [$ipaddress]"
261ad6
-	  exit $OCF_ERR_CONFIGURED
261ad6
+	  return $OCF_ERR_CONFIGURED
261ad6
 	fi
261ad6
 
261ad6
 	if ocf_is_probe; then
261ad6
@@ -407,8 +419,9 @@ srca_validate_all() {
261ad6
 	  :
261ad6
 	else
261ad6
 	  ocf_exit_reason "We are not serving [$ipaddress], hence can not make it a preferred source address"
261ad6
-	  exit $OCF_ERR_INSTALLED
261ad6
+	  return $OCF_ERR_INSTALLED
261ad6
 	fi
261ad6
+	return $OCF_SUCCESS
261ad6
 }
261ad6
 
261ad6
 if
261ad6
@@ -430,18 +443,22 @@ case $1 in
261ad6
 			;;
261ad6
 esac
261ad6
 
261ad6
-if 
261ad6
-  [ -z "$OCF_RESKEY_ipaddress" ]
261ad6
-then
261ad6
-#  usage
261ad6
-  ocf_exit_reason "Please set OCF_RESKEY_ipaddress to the preferred source IP address!"
261ad6
-  exit $OCF_ERR_CONFIGURED
261ad6
-fi
261ad6
-
261ad6
 ipaddress="$OCF_RESKEY_ipaddress"
261ad6
 
261ad6
-if [ "x$SYSTYPE" = "xLinux" ]; then
261ad6
-	srca_validate_all
261ad6
+srca_validate_all
261ad6
+rc=$?
261ad6
+if [ $rc -ne $OCF_SUCCESS ]; then
261ad6
+	case $1 in
261ad6
+		# if we can't validate the configuration during a stop, that
261ad6
+		# means the resources isn't configured correctly. There's no way
261ad6
+		# to actually stop the resource in this situation because there's
261ad6
+		# no way it could have even started. Return success here
261ad6
+		# to indicate that the resource is not running, otherwise the
261ad6
+		# stop action will fail causing the node to be fenced just because
261ad6
+		# of a mis configuration.
261ad6
+		stop) exit $OCF_SUCCESS;;
261ad6
+		*)    exit $rc;;
261ad6
+	esac
261ad6
 fi
261ad6
 
261ad6
 findif_out=`$FINDIF -C`
261ad6
-- 
261ad6
1.8.4.2
261ad6