-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding ipv6 support #1655
Open
vladsamoylik
wants to merge
3
commits into
ClusterLabs:main
Choose a base branch
from
vladsamoylik:master
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+44
−10
Open
Adding ipv6 support #1655
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,6 @@ USAGE="usage: $0 {start|stop|status|meta-data}"; | |
# | ||
############################################################################### | ||
|
||
|
||
metadata() { | ||
cat <<END | ||
<?xml version="1.0"?> | ||
|
@@ -180,7 +179,6 @@ Name of resource type to lookup in route table. | |
END | ||
} | ||
|
||
|
||
execute_cmd_as_role(){ | ||
cmd=$1 | ||
role=$2 | ||
|
@@ -240,11 +238,21 @@ ec2ip_monitor() { | |
for rtb in $(echo $OCF_RESKEY_routing_table | sed -e 's/,/ /g'); do | ||
ocf_log info "monitor: check routing table (API call) - $rtb" | ||
if [ -z "${OCF_RESKEY_routing_table_role}" ]; then | ||
cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile $region_opt --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].$OCF_RESKEY_lookup_type" | ||
if [[ "$OCF_RESKEY_ip" == *[:]* ]]; | ||
then #ipv6 | ||
cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile $region_opt --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationIpv6CidrBlock=='$OCF_RESKEY_ip/128'].$OCF_RESKEY_lookup_type" | ||
else #ipv4 | ||
cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile $region_opt --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].$OCF_RESKEY_lookup_type" | ||
fi | ||
ocf_log debug "executing command: $cmd" | ||
ROUTE_TO_INSTANCE="$($cmd)" | ||
else | ||
cmd="$OCF_RESKEY_awscli $region_opt --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].$OCF_RESKEY_lookup_type" | ||
if [[ "$OCF_RESKEY_ip" == *[:]* ]]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section should also have one less tab to fit match the rest of the code. |
||
then #ipv6 | ||
cmd="$OCF_RESKEY_awscli $region_opt --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationIpv6CidrBlock=='$OCF_RESKEY_ip/128'].$OCF_RESKEY_lookup_type" | ||
else #ipv4 | ||
cmd="$OCF_RESKEY_awscli $region_opt --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].$OCF_RESKEY_lookup_type" | ||
fi | ||
ROUTE_TO_INSTANCE="$(execute_cmd_as_role "$cmd" $OCF_RESKEY_routing_table_role)" | ||
fi | ||
ocf_log debug "Overlay IP is currently routed to ${ROUTE_TO_INSTANCE}" | ||
|
@@ -287,7 +295,12 @@ ec2ip_monitor() { | |
|
||
|
||
ec2ip_drop() { | ||
cmd="ip addr delete ${OCF_RESKEY_ip}/32 dev $OCF_RESKEY_interface" | ||
if [[ "$OCF_RESKEY_ip" == *[:]* ]]; | ||
then | ||
cmd="ip addr delete ${OCF_RESKEY_ip}/128 dev $OCF_RESKEY_interface" | ||
else | ||
cmd="ip addr delete ${OCF_RESKEY_ip}/32 dev $OCF_RESKEY_interface" | ||
fi | ||
ocf_log debug "executing command: $cmd" | ||
output=$($cmd 2>&1) | ||
rc=$? | ||
|
@@ -308,8 +321,14 @@ ec2ip_drop() { | |
fi | ||
|
||
# delete remaining route-entries if any | ||
ip route show to exact ${OCF_RESKEY_ip}/32 dev $OCF_RESKEY_interface | xargs -r ip route delete | ||
ip route show table local to exact ${OCF_RESKEY_ip}/32 dev $OCF_RESKEY_interface | xargs -r ip route delete | ||
if [[ "$OCF_RESKEY_ip" == *[:]* ]]; | ||
then | ||
ip route show to exact ${OCF_RESKEY_ip}/128 dev $OCF_RESKEY_interface | xargs -r ip route delete | ||
ip route show table local to exact ${OCF_RESKEY_ip}/128 dev $OCF_RESKEY_interface | xargs -r ip route delete | ||
else | ||
ip route show to exact ${OCF_RESKEY_ip}/32 dev $OCF_RESKEY_interface | xargs -r ip route delete | ||
ip route show table local to exact ${OCF_RESKEY_ip}/32 dev $OCF_RESKEY_interface | xargs -r ip route delete | ||
fi | ||
|
||
return $OCF_SUCCESS | ||
} | ||
|
@@ -346,11 +365,21 @@ ec2ip_get_and_configure() { | |
EC2_NETWORK_INTERFACE_ID="$(ec2ip_get_instance_eni)" | ||
for rtb in $(echo $OCF_RESKEY_routing_table | sed -e 's/,/ /g'); do | ||
if [ -z "${OCF_RESKEY_routing_table_role}" ]; then | ||
cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile $region_opt --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID" | ||
if [[ "$OCF_RESKEY_ip" == *[:]* ]]; | ||
then | ||
cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile $region_opt --output text ec2 replace-route --route-table-id $rtb --destination-ipv6-cidr-block ${OCF_RESKEY_ip}/128 --network-interface-id $EC2_NETWORK_INTERFACE_ID" | ||
else | ||
cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile $region_opt --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID" | ||
fi | ||
ocf_log debug "executing command: $cmd" | ||
$cmd | ||
else | ||
cmd="$OCF_RESKEY_awscli $region_opt --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID" | ||
if [[ "$OCF_RESKEY_ip" == *[:]* ]]; | ||
then | ||
cmd="$OCF_RESKEY_awscli $region_opt --output text ec2 replace-route --route-table-id $rtb --destination-ipv6-cidr-block ${OCF_RESKEY_ip}/128 --network-interface-id $EC2_NETWORK_INTERFACE_ID" | ||
else | ||
cmd="$OCF_RESKEY_awscli $region_opt --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID" | ||
fi | ||
update_response="$(execute_cmd_as_role "$cmd" $OCF_RESKEY_routing_table_role)" | ||
fi | ||
rc=$? | ||
|
@@ -363,7 +392,12 @@ ec2ip_get_and_configure() { | |
|
||
# Reconfigure the local ip address | ||
ec2ip_drop | ||
cmd="ip addr add ${OCF_RESKEY_ip}/32 dev $OCF_RESKEY_interface" | ||
if [[ "$OCF_RESKEY_ip" == *[:]* ]]; | ||
then | ||
cmd="ip addr add ${OCF_RESKEY_ip}/128 dev $OCF_RESKEY_interface" | ||
else | ||
cmd="ip addr add ${OCF_RESKEY_ip}/32 dev $OCF_RESKEY_interface" | ||
fi | ||
ocf_log debug "executing command: $cmd" | ||
$cmd | ||
rc=$? | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use case to avoid these bashables.
Example:
resource-agents/heartbeat/exportfs
Lines 283 to 284 in 34e75a5
And also bump the indentation back a tab for this section.