Blame SOURCES/IPaddr2-monitor_retries.patch

b94b9d
diff -uNr a/heartbeat/IPaddr2 b/heartbeat/IPaddr2
b94b9d
--- a/heartbeat/IPaddr2	2018-06-27 10:29:08.000000000 +0200
b94b9d
+++ b/heartbeat/IPaddr2	2018-06-29 16:01:50.538797379 +0200
b94b9d
@@ -80,6 +80,7 @@
b94b9d
 OCF_RESKEY_arp_bg_default=true
b94b9d
 OCF_RESKEY_run_arping_default=false
b94b9d
 OCF_RESKEY_preferred_lft_default="forever"
b94b9d
+OCF_RESKEY_monitor_retries="1"
b94b9d
 
b94b9d
 : ${OCF_RESKEY_lvs_support=${OCF_RESKEY_lvs_support_default}}
b94b9d
 : ${OCF_RESKEY_lvs_ipv6_addrlabel=${OCF_RESKEY_lvs_ipv6_addrlabel_default}}
b94b9d
@@ -92,6 +93,7 @@
b94b9d
 : ${OCF_RESKEY_arp_bg=${OCF_RESKEY_arp_bg_default}}
b94b9d
 : ${OCF_RESKEY_run_arping=${OCF_RESKEY_run_arping_default}}
b94b9d
 : ${OCF_RESKEY_preferred_lft=${OCF_RESKEY_preferred_lft_default}}
b94b9d
+: ${OCF_RESKEY_monitor_retries=${OCF_RESKEY_monitor_retries_default}}
b94b9d
 #######################################################################
b94b9d
 
b94b9d
 SENDARP=$HA_BIN/send_arp
b94b9d
@@ -368,6 +370,18 @@
b94b9d
 <content type="string" default="${OCF_RESKEY_preferred_lft_default}"/>
b94b9d
 </parameter>
b94b9d
 
b94b9d
+<parameter name="monitor_retries">
b94b9d
+<longdesc lang="en">
b94b9d
+Set number of retries to find interface in monitor-action.
b94b9d
+
b94b9d
+ONLY INCREASE IF THE AGENT HAS ISSUES FINDING YOUR NIC DURING THE
b94b9d
+MONITOR-ACTION. A HIGHER SETTING MAY LEAD TO DELAYS IN DETECTING
b94b9d
+A FAILURE.
b94b9d
+</longdesc>
b94b9d
+<shortdesc lang="en">Number of retries to find interface in monitor-action</shortdesc>
b94b9d
+<content type="string" default="${OCF_RESKEY_monitor_retries_default}"/>
b94b9d
+</parameter>
b94b9d
+
b94b9d
 </parameters>
b94b9d
 <actions>
b94b9d
 <action name="start"   timeout="20s" />
b94b9d
@@ -536,15 +550,26 @@
b94b9d
 find_interface() {
b94b9d
 	local ipaddr="$1"
b94b9d
 	local netmask="$2"
b94b9d
+	local iface=""
b94b9d
 
b94b9d
 	#
b94b9d
 	# List interfaces but exclude FreeS/WAN ipsecN virtual interfaces
b94b9d
 	#
b94b9d
-	local iface="`$IP2UTIL -o -f $FAMILY addr show \
b94b9d
+	for i in $(seq 1 $OCF_RESKEY_monitor_retries); do
b94b9d
+	    iface="`$IP2UTIL -o -f $FAMILY addr show \
b94b9d
 		| grep "\ $ipaddr/$netmask" \
b94b9d
 		| cut -d ' ' -f2 \
b94b9d
 		| grep -v '^ipsec[0-9][0-9]*$'`"
b94b9d
 
b94b9d
+	    if [ -n "$iface" ]; then
b94b9d
+		    break
b94b9d
+	    fi
b94b9d
+
b94b9d
+	    if [ $OCF_RESKEY_monitor_retries -gt 1 ]; then
b94b9d
+		sleep 1
b94b9d
+	    fi
b94b9d
+	done
b94b9d
+
b94b9d
 	echo "$iface"
b94b9d
 	return 0
b94b9d
 }