Skip to content

Commit

Permalink
Fixes mirroring timeout issue
Browse files Browse the repository at this point in the history
Fixes mirroring timeout issue Signed-off-by: Uday Kurundwade <[email protected]>
  • Loading branch information
udaysk23 committed Nov 28, 2023
1 parent 8a34a1d commit 15c2f0f
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions ocs_ci/ocs/resources/mcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit 15c2f0f

Please sign in to comment.