-
Notifications
You must be signed in to change notification settings - Fork 603
IPaddr2: add support to kill dangling IP connections #2076
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
Open
alfonso-escribano
wants to merge
4
commits into
ClusterLabs:main
Choose a base branch
from
alfonso-escribano:ipaddr2_kill_dangling_connections
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.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4c97210
Adding support to kill dangling ip connections before and after delet…
alfonso-escribano 77d1b36
Changes done as per PR#2076 feedback
alfonso-escribano 94fb124
Changes done as per PR#2076 feedback
alfonso-escribano 08e033a
Fix fi identation
alfonso-escribano 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 hidden or 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 |
|---|---|---|
|
|
@@ -93,6 +93,7 @@ OCF_RESKEY_noprefixroute_default="false" | |
| OCF_RESKEY_preferred_lft_default="forever" | ||
| OCF_RESKEY_network_namespace_default="" | ||
| OCF_RESKEY_check_link_status_default="true" | ||
| OCF_RESKEY_kill_connections_on_stop_default="false" | ||
|
|
||
| # RHEL specific defaults | ||
| if is_redhat_based; then | ||
|
|
@@ -130,6 +131,7 @@ fi | |
| : ${OCF_RESKEY_preferred_lft=${OCF_RESKEY_preferred_lft_default}} | ||
| : ${OCF_RESKEY_network_namespace=${OCF_RESKEY_network_namespace_default}} | ||
| : ${OCF_RESKEY_check_link_status=${OCF_RESKEY_check_link_status_default}} | ||
| : ${OCF_RESKEY_kill_connections_on_stop=${OCF_RESKEY_kill_connections_on_stop_default}} | ||
|
|
||
| ####################################################################### | ||
|
|
||
|
|
@@ -471,6 +473,14 @@ Consider the resource failed if the interface has status DOWN or LOWERLAYERDOWN. | |
| <shortdesc lang="en">Consider the resource failed if the interface has status DOWN or LOWERLAYERDOWN</shortdesc> | ||
| <content type="string" default="${OCF_RESKEY_check_link_status_default}"/> | ||
| </parameter> | ||
|
|
||
| <parameter name="kill_connections_on_stop"> | ||
| <longdesc lang="en"> | ||
| Kill connections using 'ss -K src IP' before deleteing interface | ||
| </longdesc> | ||
| <shortdesc lang="en">Kill connections before remove ip</shortdesc> | ||
| <content type="string" default="${OCF_RESKEY_kill_connections_on_stop_default}"/> | ||
| </parameter> | ||
| </parameters> | ||
|
|
||
| <actions> | ||
|
|
@@ -666,6 +676,37 @@ find_interface() { | |
| return 0 | ||
| } | ||
|
|
||
| # | ||
| # Kill dangling ip connections | ||
| # | ||
| kill_ip_connections() { | ||
| local ss_output="" | ||
| local ss_line="" | ||
| local ss_out_loglevel="info" | ||
|
|
||
| local ipaddr="$1" | ||
|
||
|
|
||
| check_binary ss | ||
|
|
||
| CMD="ss -Knp src $ipaddr" | ||
oalbrigt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ocf_log info "Calling $CMD" | ||
|
|
||
| ss_output=`$CMD 2>&1` | ||
| RC=$? | ||
|
|
||
| if [ $RC -ne 0 ]; then | ||
| ocf_log warn "Command $CMD failed (rc = ${THE_RC})" | ||
oalbrigt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ss_out_loglevel="error" | ||
| fi | ||
| [ -n "$ss_output" ] && echo "$ss_output" | while read ss_line; | ||
| do | ||
| ocf_log $ss_out_loglevel "$ss_line" | ||
oalbrigt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| done | ||
|
|
||
| return $OCF_SUCCESS | ||
| } | ||
|
|
||
| # | ||
| # Delete an interface | ||
| # | ||
|
|
@@ -1206,6 +1247,11 @@ ip_stop() { | |
| exit $OCF_SUCCESS | ||
| fi | ||
|
|
||
| if ocf_is_true ${OCF_RESKEY_kill_connections_on_stop}; then | ||
| kill_ip_connections $OCF_RESKEY_ip | ||
| fi | ||
|
|
||
|
|
||
| if [ -n "$IP_CIP" ] && [ $ip_status != "partial2" ]; then | ||
| if [ $ip_status = "partial" ]; then | ||
| exit $OCF_SUCCESS | ||
|
|
@@ -1240,6 +1286,9 @@ ip_stop() { | |
| restore_loopback "$OCF_RESKEY_ip" | ||
| fi | ||
| fi | ||
| if ocf_is_true ${OCF_RESKEY_kill_connections_on_stop}; then | ||
| kill_ip_connections $OCF_RESKEY_ip | ||
| fi | ||
|
|
||
| exit $OCF_SUCCESS | ||
| } | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.