diff --git a/ocs_ci/ocs/resources/mcg.py b/ocs_ci/ocs/resources/mcg.py index aa35cc83940e..25490d53085e 100644 --- a/ocs_ci/ocs/resources/mcg.py +++ b/ocs_ci/ocs/resources/mcg.py @@ -747,7 +747,7 @@ def cli_create_bucketclass( f"bucketclass create {placement_type}{name}{backingstores}{placement_policy}{replication_policy}" ) - def check_if_mirroring_is_done(self, bucket_name, timeout=140): + def check_if_mirroring_is_done(self, bucket_name, timeout=300): """ Check whether all object chunks in a bucket are mirrored across all backing stores. @@ -760,8 +760,8 @@ def check_if_mirroring_is_done(self, bucket_name, timeout=140): bool: Whether mirroring finished successfully """ - - 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 - 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 + current_percentage = (results.count(True) / len(results)) * 100 + return current_percentage + + mirror_percentage = _get_mirroring_percentage() + logger.info(f"{mirror_percentage}% mirroring is done.") + previous_percentage = 0 + while mirror_percentage < 100: + previous_percentage = mirror_percentage + try: + for mirror_percentage in TimeoutSampler(timeout, 5, _get_mirroring_percentage): + if previous_percentage == mirror_percentage: + logger.error("The mirroring process is stuck.") + else: + break + except TimeoutExpiredError: + logger.error(f"The mirroring process is stuck from last {timeout} seconds.") + assert False + mirror_percentage = _get_mirroring_percentage() + logger.info("All objects mirrored successfully.") + return True def check_backingstore_state(self, backingstore_name, desired_state, timeout=600): """