From ef641d513cdc5a5bb80a5353893cb674bffc4673 Mon Sep 17 00:00:00 2001 From: Nicolae Vartolomei Date: Thu, 11 Jul 2024 14:50:00 +0100 Subject: [PATCH] rptest: tolerate leadership changes in chunk read tests DeleteRandomChunks worker must refresh knowledge about current leader otherwise it might act on an unrelated node, report that it was unable to delete any chunks, and fail the test. --- .../tests/cloud_storage_chunk_read_path_test.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/rptest/tests/cloud_storage_chunk_read_path_test.py b/tests/rptest/tests/cloud_storage_chunk_read_path_test.py index 4f7b9b9f2901..1b49144cc5a9 100644 --- a/tests/rptest/tests/cloud_storage_chunk_read_path_test.py +++ b/tests/rptest/tests/cloud_storage_chunk_read_path_test.py @@ -506,10 +506,6 @@ def __init__(self, redpanda: RedpandaService, topic: str, n_delete=3): self.n_delete = n_delete self.deleted_chunks = 0 - leader_id = Admin(self.redpanda).get_partition_leader( - namespace='kafka', topic=self.topic, partition=0) - self.leader = self.redpanda.get_node_by_id(leader_id) - def run(self) -> None: cmd = f""" find {self.redpanda.DATA_DIR}/cloud_storage_cache -regex '.*kafka/{self.topic}/.*_chunks/[0-9]+' -print0 |\ @@ -518,11 +514,15 @@ def run(self) -> None: xargs --no-run-if-empty --null rm -v""" while not self.stop_requested: sleep(self.sleep_interval) - if self.leader in self.redpanda.started_nodes(): + leader_id = Admin(self.redpanda).get_partition_leader( + namespace='kafka', topic=self.topic, partition=0) + leader_node = self.redpanda.get_node_by_id(leader_id) + + if leader_node in self.redpanda.started_nodes(): try: - for row in self.leader.account.ssh_capture(cmd): + for row in leader_node.account.ssh_capture(cmd): self.redpanda.logger.debug( - f'{self.leader.account.hostname}: {row.strip()}') + f'{leader_node.account.hostname}: {row.strip()}') self.deleted_chunks += 1 except Exception as ex: self.redpanda.logger.info(