|
|
4d1913 |
From 9f2b9cc09f7e2df163ff95585374f860f3dc58eb Mon Sep 17 00:00:00 2001
|
|
|
4d1913 |
From: Tomas Krojzl <tomas_krojzl@cz.ibm.com>
|
|
|
4d1913 |
Date: Tue, 16 Apr 2019 18:40:29 +0200
|
|
|
4d1913 |
Subject: [PATCH 1/6] Fix for VM having multiple network interfaces
|
|
|
4d1913 |
|
|
|
4d1913 |
---
|
|
|
4d1913 |
heartbeat/aws-vpc-move-ip | 22 +++++++++++++++++++++-
|
|
|
4d1913 |
1 file changed, 21 insertions(+), 1 deletion(-)
|
|
|
4d1913 |
|
|
|
4d1913 |
diff --git a/heartbeat/aws-vpc-move-ip b/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
index 090956434..a91c2dd11 100755
|
|
|
4d1913 |
--- a/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
+++ b/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
@@ -219,8 +219,28 @@ ec2ip_drop() {
|
|
|
4d1913 |
}
|
|
|
4d1913 |
|
|
|
4d1913 |
ec2ip_get_and_configure() {
|
|
|
4d1913 |
+ cmd="ip -br link show dev $OCF_RESKEY_interface | tr -s ' ' | cut -d' ' -f3"
|
|
|
4d1913 |
+ ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
+ MAC_ADDR="$(eval $cmd)"
|
|
|
4d1913 |
+ rc=$?
|
|
|
4d1913 |
+ if [ $rc != 0 ]; then
|
|
|
4d1913 |
+ ocf_log warn "command failed, rc: $rc"
|
|
|
4d1913 |
+ return $OCF_ERR_GENERIC
|
|
|
4d1913 |
+ fi
|
|
|
4d1913 |
+ ocf_log debug "MAC address associated with interface ${OCF_RESKEY_interface}: ${MAC_ADDR}"
|
|
|
4d1913 |
+
|
|
|
4d1913 |
+ cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 describe-instances --instance-ids $EC2_INSTANCE_ID --query 'Reservations[*].Instances[*].NetworkInterfaces[*].[NetworkInterfaceId,MacAddress]' | grep ${MAC_ADDR} | cut -f1"
|
|
|
4d1913 |
+ ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
+ EC2_NETWORK_INTERFACE_ID="$(eval $cmd)"
|
|
|
4d1913 |
+ rc=$?
|
|
|
4d1913 |
+ if [ $rc != 0 ]; then
|
|
|
4d1913 |
+ ocf_log warn "command failed, rc: $rc"
|
|
|
4d1913 |
+ return $OCF_ERR_GENERIC
|
|
|
4d1913 |
+ fi
|
|
|
4d1913 |
+ ocf_log debug "network interface id associated MAC address ${MAC_ADDR}: ${EC2_NETWORK_INTERFACE_ID}"
|
|
|
4d1913 |
+
|
|
|
4d1913 |
for rtb in $(echo $OCF_RESKEY_routing_table | sed -e 's/,/ /g'); do
|
|
|
4d1913 |
- cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --instance-id $EC2_INSTANCE_ID"
|
|
|
4d1913 |
+ cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID"
|
|
|
4d1913 |
ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
$cmd
|
|
|
4d1913 |
rc=$?
|
|
|
4d1913 |
|
|
|
4d1913 |
From a871a463134ebb2456b5f37a343bf9034f5f4074 Mon Sep 17 00:00:00 2001
|
|
|
4d1913 |
From: krojzl <tomas_krojzl@cz.ibm.com>
|
|
|
4d1913 |
Date: Tue, 16 Apr 2019 18:49:32 +0200
|
|
|
4d1913 |
Subject: [PATCH 2/6] Fixing indentation
|
|
|
4d1913 |
|
|
|
4d1913 |
---
|
|
|
4d1913 |
heartbeat/aws-vpc-move-ip | 4 ++--
|
|
|
4d1913 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
4d1913 |
|
|
|
4d1913 |
diff --git a/heartbeat/aws-vpc-move-ip b/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
index a91c2dd11..a46d10d30 100755
|
|
|
4d1913 |
--- a/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
+++ b/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
@@ -227,7 +227,7 @@ ec2ip_get_and_configure() {
|
|
|
4d1913 |
ocf_log warn "command failed, rc: $rc"
|
|
|
4d1913 |
return $OCF_ERR_GENERIC
|
|
|
4d1913 |
fi
|
|
|
4d1913 |
- ocf_log debug "MAC address associated with interface ${OCF_RESKEY_interface}: ${MAC_ADDR}"
|
|
|
4d1913 |
+ ocf_log debug "MAC address associated with interface ${OCF_RESKEY_interface}: ${MAC_ADDR}"
|
|
|
4d1913 |
|
|
|
4d1913 |
cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 describe-instances --instance-ids $EC2_INSTANCE_ID --query 'Reservations[*].Instances[*].NetworkInterfaces[*].[NetworkInterfaceId,MacAddress]' | grep ${MAC_ADDR} | cut -f1"
|
|
|
4d1913 |
ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
@@ -237,7 +237,7 @@ ec2ip_get_and_configure() {
|
|
|
4d1913 |
ocf_log warn "command failed, rc: $rc"
|
|
|
4d1913 |
return $OCF_ERR_GENERIC
|
|
|
4d1913 |
fi
|
|
|
4d1913 |
- ocf_log debug "network interface id associated MAC address ${MAC_ADDR}: ${EC2_NETWORK_INTERFACE_ID}"
|
|
|
4d1913 |
+ ocf_log debug "network interface id associated MAC address ${MAC_ADDR}: ${EC2_NETWORK_INTERFACE_ID}"
|
|
|
4d1913 |
|
|
|
4d1913 |
for rtb in $(echo $OCF_RESKEY_routing_table | sed -e 's/,/ /g'); do
|
|
|
4d1913 |
cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID"
|
|
|
4d1913 |
|
|
|
4d1913 |
From 068680427dff620a948ae25f090bc154b02f17b9 Mon Sep 17 00:00:00 2001
|
|
|
4d1913 |
From: krojzl <tomas_krojzl@cz.ibm.com>
|
|
|
4d1913 |
Date: Wed, 17 Apr 2019 14:22:31 +0200
|
|
|
4d1913 |
Subject: [PATCH 3/6] Requested fix to avoid using AWS API
|
|
|
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 a46d10d30..2910552f2 100755
|
|
|
4d1913 |
--- a/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
+++ b/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
@@ -229,7 +229,7 @@ ec2ip_get_and_configure() {
|
|
|
4d1913 |
fi
|
|
|
4d1913 |
ocf_log debug "MAC address associated with interface ${OCF_RESKEY_interface}: ${MAC_ADDR}"
|
|
|
4d1913 |
|
|
|
4d1913 |
- cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 describe-instances --instance-ids $EC2_INSTANCE_ID --query 'Reservations[*].Instances[*].NetworkInterfaces[*].[NetworkInterfaceId,MacAddress]' | grep ${MAC_ADDR} | cut -f1"
|
|
|
4d1913 |
+ cmd="curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MAC_ADDR}/interface-id"
|
|
|
4d1913 |
ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
EC2_NETWORK_INTERFACE_ID="$(eval $cmd)"
|
|
|
4d1913 |
rc=$?
|
|
|
4d1913 |
|
|
|
4d1913 |
From 207a2ba66ba7196180d27674aa204980fcd25de2 Mon Sep 17 00:00:00 2001
|
|
|
4d1913 |
From: krojzl <tomas_krojzl@cz.ibm.com>
|
|
|
4d1913 |
Date: Fri, 19 Apr 2019 11:14:21 +0200
|
|
|
4d1913 |
Subject: [PATCH 4/6] More robust approach of getting MAC address
|
|
|
4d1913 |
|
|
|
4d1913 |
---
|
|
|
4d1913 |
heartbeat/aws-vpc-move-ip | 29 +++++++++++++++++++++--------
|
|
|
4d1913 |
1 file changed, 21 insertions(+), 8 deletions(-)
|
|
|
4d1913 |
|
|
|
4d1913 |
diff --git a/heartbeat/aws-vpc-move-ip b/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
index 2910552f2..3a848b7e3 100755
|
|
|
4d1913 |
--- a/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
+++ b/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
@@ -219,15 +219,28 @@ ec2ip_drop() {
|
|
|
4d1913 |
}
|
|
|
4d1913 |
|
|
|
4d1913 |
ec2ip_get_and_configure() {
|
|
|
4d1913 |
- cmd="ip -br link show dev $OCF_RESKEY_interface | tr -s ' ' | cut -d' ' -f3"
|
|
|
4d1913 |
- ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
- MAC_ADDR="$(eval $cmd)"
|
|
|
4d1913 |
- rc=$?
|
|
|
4d1913 |
- if [ $rc != 0 ]; then
|
|
|
4d1913 |
- ocf_log warn "command failed, rc: $rc"
|
|
|
4d1913 |
- return $OCF_ERR_GENERIC
|
|
|
4d1913 |
+ MAC_FILE="/sys/class/net/${OCF_RESKEY_interface}/address"
|
|
|
4d1913 |
+ if [ -f $MAC_FILE ]; then
|
|
|
4d1913 |
+ cmd="cat ${MAC_FILE}"
|
|
|
4d1913 |
+ ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
+ MAC_ADDR="$(eval $cmd)"
|
|
|
4d1913 |
+ rc=$?
|
|
|
4d1913 |
+ if [ $rc != 0 ]; then
|
|
|
4d1913 |
+ ocf_log warn "command failed, rc: $rc"
|
|
|
4d1913 |
+ return $OCF_ERR_GENERIC
|
|
|
4d1913 |
+ fi
|
|
|
4d1913 |
+ ocf_log debug "MAC address associated with interface ${OCF_RESKEY_interface}: ${MAC_ADDR}"
|
|
|
4d1913 |
+ else
|
|
|
4d1913 |
+ cmd="ip -br link show dev ${OCF_RESKEY_interface} | tr -s ' ' | cut -d' ' -f3"
|
|
|
4d1913 |
+ ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
+ MAC_ADDR="$(eval $cmd)"
|
|
|
4d1913 |
+ rc=$?
|
|
|
4d1913 |
+ if [ $rc != 0 ]; then
|
|
|
4d1913 |
+ ocf_log warn "command failed, rc: $rc"
|
|
|
4d1913 |
+ return $OCF_ERR_GENERIC
|
|
|
4d1913 |
+ fi
|
|
|
4d1913 |
+ ocf_log debug "MAC address associated with interface ${OCF_RESKEY_interface}: ${MAC_ADDR}"
|
|
|
4d1913 |
fi
|
|
|
4d1913 |
- ocf_log debug "MAC address associated with interface ${OCF_RESKEY_interface}: ${MAC_ADDR}"
|
|
|
4d1913 |
|
|
|
4d1913 |
cmd="curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MAC_ADDR}/interface-id"
|
|
|
4d1913 |
ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
|
|
|
4d1913 |
From cdcc12a9c1431125b0d5298176e5242bfc9fbe29 Mon Sep 17 00:00:00 2001
|
|
|
4d1913 |
From: krojzl <tomas_krojzl@cz.ibm.com>
|
|
|
4d1913 |
Date: Fri, 19 Apr 2019 11:20:09 +0200
|
|
|
4d1913 |
Subject: [PATCH 5/6] Moving shared part outside if
|
|
|
4d1913 |
|
|
|
4d1913 |
---
|
|
|
4d1913 |
heartbeat/aws-vpc-move-ip | 25 +++++++++----------------
|
|
|
4d1913 |
1 file changed, 9 insertions(+), 16 deletions(-)
|
|
|
4d1913 |
|
|
|
4d1913 |
diff --git a/heartbeat/aws-vpc-move-ip b/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
index 3a848b7e3..bfe23e5bf 100755
|
|
|
4d1913 |
--- a/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
+++ b/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
@@ -222,26 +222,19 @@ ec2ip_get_and_configure() {
|
|
|
4d1913 |
MAC_FILE="/sys/class/net/${OCF_RESKEY_interface}/address"
|
|
|
4d1913 |
if [ -f $MAC_FILE ]; then
|
|
|
4d1913 |
cmd="cat ${MAC_FILE}"
|
|
|
4d1913 |
- ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
- MAC_ADDR="$(eval $cmd)"
|
|
|
4d1913 |
- rc=$?
|
|
|
4d1913 |
- if [ $rc != 0 ]; then
|
|
|
4d1913 |
- ocf_log warn "command failed, rc: $rc"
|
|
|
4d1913 |
- return $OCF_ERR_GENERIC
|
|
|
4d1913 |
- fi
|
|
|
4d1913 |
- ocf_log debug "MAC address associated with interface ${OCF_RESKEY_interface}: ${MAC_ADDR}"
|
|
|
4d1913 |
else
|
|
|
4d1913 |
cmd="ip -br link show dev ${OCF_RESKEY_interface} | tr -s ' ' | cut -d' ' -f3"
|
|
|
4d1913 |
- ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
- MAC_ADDR="$(eval $cmd)"
|
|
|
4d1913 |
- rc=$?
|
|
|
4d1913 |
- if [ $rc != 0 ]; then
|
|
|
4d1913 |
- ocf_log warn "command failed, rc: $rc"
|
|
|
4d1913 |
- return $OCF_ERR_GENERIC
|
|
|
4d1913 |
- fi
|
|
|
4d1913 |
- ocf_log debug "MAC address associated with interface ${OCF_RESKEY_interface}: ${MAC_ADDR}"
|
|
|
4d1913 |
fi
|
|
|
4d1913 |
|
|
|
4d1913 |
+ ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
+ MAC_ADDR="$(eval $cmd)"
|
|
|
4d1913 |
+ rc=$?
|
|
|
4d1913 |
+ if [ $rc != 0 ]; then
|
|
|
4d1913 |
+ ocf_log warn "command failed, rc: $rc"
|
|
|
4d1913 |
+ return $OCF_ERR_GENERIC
|
|
|
4d1913 |
+ fi
|
|
|
4d1913 |
+ ocf_log debug "MAC address associated with interface ${OCF_RESKEY_interface}: ${MAC_ADDR}"
|
|
|
4d1913 |
+
|
|
|
4d1913 |
cmd="curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MAC_ADDR}/interface-id"
|
|
|
4d1913 |
ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
EC2_NETWORK_INTERFACE_ID="$(eval $cmd)"
|
|
|
4d1913 |
|
|
|
4d1913 |
From c3fc114fc64f6feb015c5342923fd2afc367ae28 Mon Sep 17 00:00:00 2001
|
|
|
4d1913 |
From: krojzl <tomas_krojzl@cz.ibm.com>
|
|
|
4d1913 |
Date: Fri, 19 Apr 2019 11:22:55 +0200
|
|
|
4d1913 |
Subject: [PATCH 6/6] Linting adjustment
|
|
|
4d1913 |
|
|
|
4d1913 |
---
|
|
|
4d1913 |
heartbeat/aws-vpc-move-ip | 1 -
|
|
|
4d1913 |
1 file changed, 1 deletion(-)
|
|
|
4d1913 |
|
|
|
4d1913 |
diff --git a/heartbeat/aws-vpc-move-ip b/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
index bfe23e5bf..2757c27d0 100755
|
|
|
4d1913 |
--- a/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
+++ b/heartbeat/aws-vpc-move-ip
|
|
|
4d1913 |
@@ -225,7 +225,6 @@ ec2ip_get_and_configure() {
|
|
|
4d1913 |
else
|
|
|
4d1913 |
cmd="ip -br link show dev ${OCF_RESKEY_interface} | tr -s ' ' | cut -d' ' -f3"
|
|
|
4d1913 |
fi
|
|
|
4d1913 |
-
|
|
|
4d1913 |
ocf_log debug "executing command: $cmd"
|
|
|
4d1913 |
MAC_ADDR="$(eval $cmd)"
|
|
|
4d1913 |
rc=$?
|