Blame SOURCES/bz1895811-aws-vpc-move-ip-dont-warn-for-expected-scenarios.patch

bb66af
From 8d459216c9718269303b9caf227a971d73ec4df9 Mon Sep 17 00:00:00 2001
bb66af
From: Reid Wahl <nrwahl@protonmail.com>
bb66af
Date: Thu, 27 Aug 2020 01:34:01 -0700
bb66af
Subject: [PATCH] aws-vpc-move-ip: Don't warn for expected scenarios
bb66af
bb66af
Make log levels more appropriate to the situation. Before this patch, a
bb66af
normal start looked like this:
bb66af
bb66af
Operation start for aws-vip (ocf:heartbeat:aws-vpc-move-ip) returned: 'ok' (0)
bb66af
 >  stderr: Nov 09 02:38:20 INFO: EC2: Moving IP address 10.0.1.65 to this host by adjusting routing table rtb-01b4ea1ae0ec0a4d9
bb66af
 >  stderr: Nov 09 02:38:20 INFO: monitor: check routing table (API call) - rtb-01b4ea1ae0ec0a4d9
bb66af
 >  stderr: Nov 09 02:38:22 WARNING: IP 10.0.1.65 not assigned to running interface
bb66af
 >  stderr: Nov 09 02:38:22 INFO: EC2: Adjusting routing table and locally configuring IP address
bb66af
 >  stderr: RTNETLINK answers: Cannot assign requested address
bb66af
 >  stderr: Nov 09 02:38:24 WARNING: command failed, rc 2
bb66af
 >  stderr: Nov 09 02:38:24 INFO: monitor: check routing table (API call) - rtb-01b4ea1ae0ec0a4d9
bb66af
bb66af
Now it looks like this:
bb66af
bb66af
Operation start for aws-vip (ocf:heartbeat:aws-vpc-move-ip) returned: 'ok' (0)
bb66af
 >  stderr: Nov 09 02:40:43 INFO: EC2: Moving IP address 10.0.1.65 to this host by adjusting routing table rtb-01b4ea1ae0ec0a4d9
bb66af
 >  stderr: Nov 09 02:40:43 INFO: monitor: check routing table (API call) - rtb-01b4ea1ae0ec0a4d9
bb66af
 >  stderr: Nov 09 02:40:44 INFO: IP 10.0.1.65 not assigned to running interface
bb66af
 >  stderr: Nov 09 02:40:44 INFO: EC2: Adjusting routing table and locally configuring IP address
bb66af
 >  stderr: Nov 09 02:40:46 INFO: monitor: check routing table (API call) - rtb-01b4ea1ae0ec0a4d9
bb66af
bb66af
Under normal circumstances, the call to `ec2ip_drop()` within
bb66af
`ec2ip_get_and_configure` should not be required at all. The drop
bb66af
function deletes the address before the get_and_configure function
bb66af
immediately re-adds the address. This call could probably be removed
bb66af
altogether. Instead, I left the call and silenced its output just in
bb66af
case of unexpected edge cases.
bb66af
bb66af
Resolves: RHBZ#1895811
bb66af
bb66af
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
bb66af
---
bb66af
 heartbeat/aws-vpc-move-ip | 23 ++++++++++++++++++++---
bb66af
 1 file changed, 20 insertions(+), 3 deletions(-)
bb66af
bb66af
diff --git a/heartbeat/aws-vpc-move-ip b/heartbeat/aws-vpc-move-ip
bb66af
index a5b28ad92..72a89ecb1 100755
bb66af
--- a/heartbeat/aws-vpc-move-ip
bb66af
+++ b/heartbeat/aws-vpc-move-ip
bb66af
@@ -270,7 +270,13 @@ ec2ip_monitor() {
bb66af
 	ocf_log debug "executing command: $cmd"
bb66af
 	RESULT=$($cmd | grep "$OCF_RESKEY_ip")
bb66af
 	if [ -z "$RESULT" ]; then
bb66af
-		ocf_log warn "IP $OCF_RESKEY_ip not assigned to running interface"
bb66af
+		if [ "$__OCF_ACTION" = "monitor" ] && ! ocf_is_probe; then
bb66af
+			level="error"
bb66af
+		else
bb66af
+			level="info"
bb66af
+		fi
bb66af
+
bb66af
+		ocf_log "$level" "IP $OCF_RESKEY_ip not assigned to running interface"
bb66af
 		return $OCF_NOT_RUNNING
bb66af
 	fi
bb66af
 
bb66af
@@ -282,11 +288,22 @@ ec2ip_monitor() {
bb66af
 ec2ip_drop() {
bb66af
 	cmd="ip addr delete ${OCF_RESKEY_ip}/32 dev $OCF_RESKEY_interface"
bb66af
 	ocf_log debug "executing command: $cmd"
bb66af
-	$cmd
bb66af
+	output=$($cmd 2>&1)
bb66af
 	rc=$?
bb66af
+
bb66af
 	if [ "$rc" -gt 0 ]; then
bb66af
-		ocf_log warn "command failed, rc $rc"
bb66af
+		if [ "$__OCF_ACTION" = "start" ]; then
bb66af
+			# expected to fail during start
bb66af
+			level="debug"
bb66af
+		else
bb66af
+			level="warn"
bb66af
+		fi
bb66af
+
bb66af
+		ocf_log "$level" "command failed, rc $rc"
bb66af
+		ocf_log "$level" "output/error: $output"
bb66af
 		return $OCF_ERR_GENERIC
bb66af
+	else
bb66af
+		ocf_log debug "output/error: $output"
bb66af
 	fi
bb66af
 
bb66af
 	# delete remaining route-entries if any