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

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