Skip to content

Commit 912fb11

Browse files
committed
fix(nemesis): another place of cm
1 parent 458771f commit 912fb11

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

sdcm/nemesis.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -5520,13 +5520,14 @@ def drop_keyspace(node):
55205520

55215521
simulate_node_unavailability = node_operations.block_scylla_ports if use_iptables else node_operations.pause_scylla_with_sigstop
55225522
with (self.run_nemesis(node_list=self.cluster.nodes, nemesis_label=f"Running {simulate_node_unavailability.__name__}") as working_node,
5523-
node_operations.block_loaders_payload_from_scylla_node(self.target_node, self.loaders.nodes),
55245523
ExitStack() as stack):
5524+
55255525
stack.callback(drop_keyspace, node=working_node)
55265526
target_host_id = self.target_node.host_id
55275527
stack.callback(self._remove_node_add_node, verification_node=working_node, node_to_remove=self.target_node,
55285528
remove_node_host_id=target_host_id)
5529-
5529+
stack.enter_context(node_operations.block_loaders_payload_for_scylla_node(
5530+
self.target_node, loader_nodes=self.loaders.nodes))
55305531
self.tester.create_keyspace(keyspace_name, replication_factor=3)
55315532
self.tester.create_table(name=table_name, keyspace_name=keyspace_name, key_type="bigint",
55325533
columns={"name": "text"})

sdcm/utils/nemesis_utils/node_operations.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def pause_scylla_with_sigstop(target_node: BaseNode):
3939

4040

4141
@contextlib.contextmanager
42-
def block_loaders_payload_from_scylla_node(scylla_node: BaseNode, loader_nodes: list[BaseNode]):
42+
def block_loaders_payload_for_scylla_node(scylla_node: BaseNode, loader_nodes: list[BaseNode]):
4343
ports = [9042, 9142, 19042, 19142]
4444
scylla_node.install_package("iptables")
4545
scylla_node.start_service("iptables", ignore_status=True)
@@ -52,13 +52,14 @@ def block_loaders_payload_from_scylla_node(scylla_node: BaseNode, loader_nodes:
5252
scylla_node.remoter.sudo(
5353
f"ip6tables -A INPUT -s {','.join(blocking_ips)} -p tcp --dport {port} -j DROP", ignore_status=True)
5454
yield
55-
scylla_node.log.debug("Remove all iptable rules %s", scylla_node.name)
56-
for port in ports:
57-
scylla_node.remoter.sudo(
58-
f"iptables -D INPUT -s {','.join(blocking_ips)} -p tcp --dport {port} -j DROP", ignore_status=True)
59-
scylla_node.remoter.sudo(
60-
f"ip6tables -D INPUT -s {','.join(blocking_ips)} -p tcp --dport {port} -j DROP", ignore_status=True)
61-
scylla_node.stop_service("iptables", ignore_status=True)
55+
# if scylla_node is alive, then delete the iptables rules
56+
if scylla_node.remoter.is_up():
57+
for port in ports:
58+
scylla_node.remoter.sudo(
59+
f"iptables -D INPUT -s {','.join(blocking_ips)} -p tcp --dport {port} -j DROP", ignore_status=True)
60+
scylla_node.remoter.sudo(
61+
f"ip6tables -D INPUT -s {','.join(blocking_ips)} -p tcp --dport {port} -j DROP", ignore_status=True)
62+
scylla_node.stop_service("iptables", ignore_status=True)
6263

6364

6465
def is_node_removed_from_cluster(removed_node: BaseNode, verification_node: BaseNode) -> bool:

0 commit comments

Comments
 (0)