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

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