Blame SOURCES/IPaddr2-monitor_retries.patch

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