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(