From 7cd2d847c56b596d85bfdd0316659dfb58f105a2 Mon Sep 17 00:00:00 2001 From: Uday Kurundwade Date: Mon, 6 Nov 2023 13:32:39 +0530 Subject: [PATCH] Fixes mirroring timeout issue Signed-off-by: uday kurundwade --- ocs_ci/ocs/resources/mcg.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/ocs_ci/ocs/resources/mcg.py b/ocs_ci/ocs/resources/mcg.py index aa35cc83940e..ecc63998bf59 100644 --- a/ocs_ci/ocs/resources/mcg.py +++ b/ocs_ci/ocs/resources/mcg.py @@ -761,7 +761,7 @@ def check_if_mirroring_is_done(self, bucket_name, timeout=140): """ - def _check_mirroring(): + def _get_mirroring_percentage(): results = [] obj_list = ( self.send_rpc_query( @@ -798,21 +798,26 @@ def _check_mirroring(): results.append(True) else: results.append(False) - - return all(results) - - try: - for mirroring_is_complete in TimeoutSampler(timeout, 5, _check_mirroring): - if mirroring_is_complete: - logger.info("All objects mirrored successfully.") - return True + current_percentage = (results.count(True) / len(results)) * 100 + return current_percentage + + mirror_percentage = _get_mirroring_percentage() + logger.info(f"{mirror_percentage}% mirroring is .") + previous_percentage = 0 + while mirror_percentage < 100: + previous_percentage = mirror_percentage + for i in range(timeout): + mirror_percentage = _get_mirroring_percentage() + if previous_percentage == mirror_percentage: + sleep(3) + if i + 1 == timeout: + logger.error("The mirroring process is stuck.") + assert False else: - logger.info("Waiting for the mirroring process to finish...") - except TimeoutExpiredError: - logger.error( - "The mirroring process did not complete within the time limit." - ) - assert False + break + mirror_percentage = _get_mirroring_percentage() + logger.info("All objects mirrored successfully.") + return True def check_backingstore_state(self, backingstore_name, desired_state, timeout=600): """