Skip to content

Commit

Permalink
Fixes mirroring timeout issue (#8658)
Browse files Browse the repository at this point in the history
Fixes mirroring timeout issue Signed-off-by: Uday Kurundwade <[email protected]>

Co-authored-by: Uday Kurundwade <[email protected]>
  • Loading branch information
udaysk23 and udaysk23 authored Dec 12, 2023
1 parent de1bb65 commit 3251d5f
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions ocs_ci/ocs/resources/mcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,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.
Expand All @@ -738,12 +738,12 @@ def check_if_mirroring_is_done(self, bucket_name, timeout=140):
bucket_name: The name of the bucket that should be checked
timeout: timeout in seconds to check if mirroring
Returns:
bool: Whether mirroring finished successfully
Raises:
AssertionError: In case mirroring is not done in defined time.
"""

def _check_mirroring():
def _get_mirroring_percentage():
results = []
obj_list = (
self.send_rpc_query(
Expand Down Expand Up @@ -780,21 +780,29 @@ 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.warning("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.")

def check_backingstore_state(self, backingstore_name, desired_state, timeout=600):
"""
Expand Down

0 comments on commit 3251d5f

Please sign in to comment.