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 6, 2023
1 parent 8a34a1d commit fc77961
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions ocs_ci/ocs/resources/mcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
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):
"""
Expand Down

0 comments on commit fc77961

Please sign in to comment.