Blame SOURCES/bz1693662-aws-vpc-move-ip-avoid-possible-race-condition.patch

4d1913
From 57f695d336cab33c61e754e463654ad6400f7b58 Mon Sep 17 00:00:00 2001
4d1913
From: gguifelixamz <fguilher@amazon.com>
4d1913
Date: Tue, 27 Nov 2018 17:06:05 +0000
4d1913
Subject: [PATCH 1/4] Enable --query flag in DescribeRouteTable API call to
4d1913
 avoid race condition with grep
4d1913
4d1913
---
4d1913
 heartbeat/aws-vpc-move-ip | 5 +++--
4d1913
 1 file changed, 3 insertions(+), 2 deletions(-)
4d1913
4d1913
diff --git a/heartbeat/aws-vpc-move-ip b/heartbeat/aws-vpc-move-ip
4d1913
index 9b2043aca..d2aed7490 100755
4d1913
--- a/heartbeat/aws-vpc-move-ip
4d1913
+++ b/heartbeat/aws-vpc-move-ip
4d1913
@@ -167,9 +167,10 @@ ec2ip_validate() {
4d1913
 ec2ip_monitor() {
4d1913
 	if ocf_is_true ${OCF_RESKEY_monapi} || [ "$__OCF_ACTION" = "start" ] || ocf_is_probe; then
4d1913
 		ocf_log info "monitor: check routing table (API call)"
4d1913
-		cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 describe-route-tables --route-table-ids $OCF_RESKEY_routing_table"
4d1913
+                cmd=''$OCF_RESKEY_awscli' --profile '$OCF_RESKEY_profile' --output text ec2 describe-route-tables --route-table-ids '$OCF_RESKEY_routing_table' --query 'RouteTables[*].Routes[?DestinationCidrBlock==\`$OCF_RESKEY_address/32\`].InstanceId''
4d1913
 		ocf_log debug "executing command: $cmd"
4d1913
-		ROUTE_TO_INSTANCE="$($cmd | grep $OCF_RESKEY_ip | awk '{ print $3 }')"
4d1913
+                ROUTE_TO_INSTANCE=$($cmd)
4d1913
+                ocf_log debug "Overlay IP is currently routed to ${ROUTE_TO_INSTANCE}"
4d1913
 		if [ -z "$ROUTE_TO_INSTANCE" ]; then
4d1913
 			ROUTE_TO_INSTANCE="<unknown>"
4d1913
 		fi
4d1913
4d1913
From 4d6371aca5dca35b902a480e07a08c1dc3373ca5 Mon Sep 17 00:00:00 2001
4d1913
From: gguifelixamz <fguilher@amazon.com>
4d1913
Date: Thu, 29 Nov 2018 11:39:26 +0000
4d1913
Subject: [PATCH 2/4] aws-vpc-move-ip: Fixed outer quotes and removed inner
4d1913
 quotes
4d1913
4d1913
---
4d1913
 heartbeat/aws-vpc-move-ip | 2 +-
4d1913
 1 file changed, 1 insertion(+), 1 deletion(-)
4d1913
4d1913
diff --git a/heartbeat/aws-vpc-move-ip b/heartbeat/aws-vpc-move-ip
4d1913
index d2aed7490..ced69bd13 100755
4d1913
--- a/heartbeat/aws-vpc-move-ip
4d1913
+++ b/heartbeat/aws-vpc-move-ip
4d1913
@@ -167,7 +167,7 @@ ec2ip_validate() {
4d1913
 ec2ip_monitor() {
4d1913
 	if ocf_is_true ${OCF_RESKEY_monapi} || [ "$__OCF_ACTION" = "start" ] || ocf_is_probe; then
4d1913
 		ocf_log info "monitor: check routing table (API call)"
4d1913
-                cmd=''$OCF_RESKEY_awscli' --profile '$OCF_RESKEY_profile' --output text ec2 describe-route-tables --route-table-ids '$OCF_RESKEY_routing_table' --query 'RouteTables[*].Routes[?DestinationCidrBlock==\`$OCF_RESKEY_address/32\`].InstanceId''
4d1913
+                cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 describe-route-tables --route-table-ids $OCF_RESKEY_routing_table --query RouteTables[*].Routes[?DestinationCidrBlock==\`$OCF_RESKEY_address/32\`].InstanceId"
4d1913
 		ocf_log debug "executing command: $cmd"
4d1913
                 ROUTE_TO_INSTANCE=$($cmd)
4d1913
                 ocf_log debug "Overlay IP is currently routed to ${ROUTE_TO_INSTANCE}"
4d1913
4d1913
From 09f4b061690a0e681aaf7314f1fc3e6f4e597cc8 Mon Sep 17 00:00:00 2001
4d1913
From: gguifelixamz <fguilher@amazon.com>
4d1913
Date: Thu, 29 Nov 2018 11:55:05 +0000
4d1913
Subject: [PATCH 3/4] aws-vpc-move-ip: Replaced indentation spaces with tabs
4d1913
 for consistency with the rest of the code
4d1913
4d1913
---
4d1913
 heartbeat/aws-vpc-move-ip | 6 +++---
4d1913
 1 file changed, 3 insertions(+), 3 deletions(-)
4d1913
4d1913
diff --git a/heartbeat/aws-vpc-move-ip b/heartbeat/aws-vpc-move-ip
4d1913
index ced69bd13..3e827283e 100755
4d1913
--- a/heartbeat/aws-vpc-move-ip
4d1913
+++ b/heartbeat/aws-vpc-move-ip
4d1913
@@ -167,10 +167,10 @@ ec2ip_validate() {
4d1913
 ec2ip_monitor() {
4d1913
 	if ocf_is_true ${OCF_RESKEY_monapi} || [ "$__OCF_ACTION" = "start" ] || ocf_is_probe; then
4d1913
 		ocf_log info "monitor: check routing table (API call)"
4d1913
-                cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 describe-route-tables --route-table-ids $OCF_RESKEY_routing_table --query RouteTables[*].Routes[?DestinationCidrBlock==\`$OCF_RESKEY_address/32\`].InstanceId"
4d1913
+		cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 describe-route-tables --route-table-ids $OCF_RESKEY_routing_table --query RouteTables[*].Routes[?DestinationCidrBlock==\`$OCF_RESKEY_address/32\`].InstanceId"
4d1913
 		ocf_log debug "executing command: $cmd"
4d1913
-                ROUTE_TO_INSTANCE=$($cmd)
4d1913
-                ocf_log debug "Overlay IP is currently routed to ${ROUTE_TO_INSTANCE}"
4d1913
+		ROUTE_TO_INSTANCE=$($cmd)
4d1913
+		ocf_log debug "Overlay IP is currently routed to ${ROUTE_TO_INSTANCE}"
4d1913
 		if [ -z "$ROUTE_TO_INSTANCE" ]; then
4d1913
 			ROUTE_TO_INSTANCE="<unknown>"
4d1913
 		fi
4d1913
4d1913
From fcf85551ce70cb4fb7ce24e21c361fdbe6fcce6b Mon Sep 17 00:00:00 2001
4d1913
From: gguifelixamz <fguilher@amazon.com>
4d1913
Date: Thu, 29 Nov 2018 13:07:32 +0000
4d1913
Subject: [PATCH 4/4] aws-vpc-move-ip: In cmd variable on ec2ip_monitor():
4d1913
 replaced _address with _ip and modified to use single quotes
4d1913
4d1913
---
4d1913
 heartbeat/aws-vpc-move-ip | 2 +-
4d1913
 1 file changed, 1 insertion(+), 1 deletion(-)
4d1913
4d1913
diff --git a/heartbeat/aws-vpc-move-ip b/heartbeat/aws-vpc-move-ip
4d1913
index 3e827283e..331ee184f 100755
4d1913
--- a/heartbeat/aws-vpc-move-ip
4d1913
+++ b/heartbeat/aws-vpc-move-ip
4d1913
@@ -167,7 +167,7 @@ ec2ip_validate() {
4d1913
 ec2ip_monitor() {
4d1913
 	if ocf_is_true ${OCF_RESKEY_monapi} || [ "$__OCF_ACTION" = "start" ] || ocf_is_probe; then
4d1913
 		ocf_log info "monitor: check routing table (API call)"
4d1913
-		cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 describe-route-tables --route-table-ids $OCF_RESKEY_routing_table --query RouteTables[*].Routes[?DestinationCidrBlock==\`$OCF_RESKEY_address/32\`].InstanceId"
4d1913
+		cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 describe-route-tables --route-table-ids $OCF_RESKEY_routing_table --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].InstanceId"
4d1913
 		ocf_log debug "executing command: $cmd"
4d1913
 		ROUTE_TO_INSTANCE=$($cmd)
4d1913
 		ocf_log debug "Overlay IP is currently routed to ${ROUTE_TO_INSTANCE}"