-
Notifications
You must be signed in to change notification settings - Fork 100
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
fix(nemesis): add support ipv6 for refuse connection for banned node #10594
Open
aleksbykov
wants to merge
1
commit into
scylladb:master
Choose a base branch
from
aleksbykov:fix-10434-increase-timeout-to-wait-down
base: master
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 all commits
Commits
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
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 |
---|---|---|
|
@@ -9,31 +9,66 @@ | |
|
||
|
||
@contextlib.contextmanager | ||
def block_scylla_ports(target_node: "BaseNode", ports: list[int] | None = None): | ||
def block_scylla_ports(target_node: BaseNode, ports: list[int] | None = None): | ||
ports = ports or [7001, 7000, 9042, 9142, 19042, 19142] | ||
target_node.install_package("iptables") | ||
target_node.start_service("iptables", ignore_status=True) | ||
target_node.log.debug("Block connections %s", target_node.name) | ||
for port in ports: | ||
target_node.remoter.sudo(f"iptables -A INPUT -p tcp --dport {port} -j DROP") | ||
target_node.remoter.sudo(f"iptables -A OUTPUT -p tcp --dport {port} -j DROP") | ||
target_node.remoter.sudo(f"ip6tables -A INPUT -p tcp --dport {port} -j DROP") | ||
target_node.remoter.sudo(f"ip6tables -A OUTPUT -p tcp --dport {port} -j DROP") | ||
yield | ||
target_node.log.debug("Remove all iptable rules %s", target_node.name) | ||
for port in ports: | ||
target_node.remoter.sudo(f"iptables -D INPUT -p tcp --dport {port} -j DROP") | ||
target_node.remoter.sudo(f"iptables -D OUTPUT -p tcp --dport {port} -j DROP") | ||
target_node.remoter.sudo(f"ip6tables -D INPUT -p tcp --dport {port} -j DROP") | ||
target_node.remoter.sudo(f"ip6tables -D OUTPUT -p tcp --dport {port} -j DROP") | ||
target_node.stop_service("iptables", ignore_status=True) | ||
|
||
|
||
@contextlib.contextmanager | ||
def pause_scylla_with_sigstop(target_node: "BaseNode"): | ||
def pause_scylla_with_sigstop(target_node: BaseNode): | ||
target_node.log.debug("Send signal SIGSTOP to scylla process on node %s", target_node.name) | ||
target_node.remoter.sudo("pkill --signal SIGSTOP -e scylla", timeout=60) | ||
yield | ||
target_node.log.debug("Send signal SIGCONT to scylla process on node %s", target_node.name) | ||
target_node.remoter.sudo(cmd="pkill --signal SIGCONT -e scylla", timeout=60) | ||
|
||
|
||
@contextlib.contextmanager | ||
def block_loaders_payload_for_scylla_node(scylla_node: BaseNode, loader_nodes: list[BaseNode]): | ||
""" Block connections from loaders to cql ports on scylla node | ||
|
||
Make the Scylla node inaccessible to loaders by blocking | ||
any subsequent connections to the Scylla node. | ||
This ensures that the stress tool can continue to operate without failure | ||
even if the Scylla node is banned and removed from the cluster. | ||
""" | ||
ports = [9042, 9142, 19042, 19142] | ||
scylla_node.install_package("iptables") | ||
scylla_node.start_service("iptables", ignore_status=True) | ||
loader_nodes_names = [node.name for node in loader_nodes] | ||
blocking_ips = [node.ip_address for node in loader_nodes] | ||
scylla_node.log.debug("Block connections on %s from loader nodes %s", scylla_node.name, loader_nodes_names) | ||
for port in ports: | ||
scylla_node.remoter.sudo( | ||
f"iptables -A INPUT -s {','.join(blocking_ips)} -p tcp --dport {port} -j DROP", ignore_status=True) | ||
scylla_node.remoter.sudo( | ||
f"ip6tables -A INPUT -s {','.join(blocking_ips)} -p tcp --dport {port} -j DROP", ignore_status=True) | ||
yield | ||
# if scylla_node is alive, then delete the iptables rules | ||
if scylla_node.remoter.is_up(): | ||
for port in ports: | ||
scylla_node.remoter.sudo( | ||
f"iptables -D INPUT -s {','.join(blocking_ips)} -p tcp --dport {port} -j DROP", ignore_status=True) | ||
scylla_node.remoter.sudo( | ||
f"ip6tables -D INPUT -s {','.join(blocking_ips)} -p tcp --dport {port} -j DROP", ignore_status=True) | ||
scylla_node.stop_service("iptables", ignore_status=True) | ||
|
||
|
||
def is_node_removed_from_cluster(removed_node: BaseNode, verification_node: BaseNode) -> bool: | ||
LOGGER.debug("Verification node %s", verification_node.name) | ||
cluster_status: Optional[dict] = removed_node.parent_cluster.get_nodetool_status( | ||
|
@@ -48,4 +83,6 @@ def is_node_removed_from_cluster(removed_node: BaseNode, verification_node: Base | |
|
||
def is_node_seen_as_down(down_node: BaseNode, verification_node: BaseNode) -> bool: | ||
LOGGER.debug("Verification node %s", verification_node.name) | ||
return down_node not in verification_node.parent_cluster.get_nodes_up_and_normal(verification_node) | ||
nodes_status = verification_node.parent_cluster.get_nodetool_status(verification_node, dc_aware=False) | ||
down_node_status = nodes_status.get(down_node.ip_address) | ||
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. shouln't use 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. It will be the same as ip_address and we use it everywhere with nodetool_status |
||
return (not down_node_status or down_node_status["state"] == "DN") |
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.
please add docstring why this is needed
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.
added