From 7a7fb5b820d7d418384fb1af5ead3d7b3d31535d Mon Sep 17 00:00:00 2001 From: Bala Konda Reddy M Date: Fri, 21 Aug 2020 16:06:46 +0530 Subject: [Libfix] Add interval_check for monitor_heal_completion Adding a parameter `interval_check` will ease the user and help in the reducing the waiting time for heal in scenarios. By default, ls -l | grep -ve "xattrop-" | wc -l is checked for every 2 minutes. Problem: I have 100 files that needs to be healed, after 2 minutes. suppose there are only 2/3 files that needs to be healed. With the existing approach the next check will wait for whole 2 minutes even though the files would have healed by 10 seconds after previouscheck. Solution: Giving an option for the user to check at which interval to check for the files that needs to healed, we can reduce the unnecssary waiting time. It won't affect the existing cases as the interval_check is defaults to 120. Change-Id: Ib288c75549644b6f6c94b5288f1c07cce7933915 Signed-off-by: Bala Konda Reddy M --- glustolibs-gluster/glustolibs/gluster/heal_libs.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'glustolibs-gluster/glustolibs/gluster') diff --git a/glustolibs-gluster/glustolibs/gluster/heal_libs.py b/glustolibs-gluster/glustolibs/gluster/heal_libs.py index 6c4ff709f..91d720e41 100755 --- a/glustolibs-gluster/glustolibs/gluster/heal_libs.py +++ b/glustolibs-gluster/glustolibs/gluster/heal_libs.py @@ -135,7 +135,8 @@ def are_all_self_heal_daemons_are_online(mnode, volname): return False -def monitor_heal_completion(mnode, volname, timeout_period=1200, bricks=None): +def monitor_heal_completion(mnode, volname, timeout_period=1200, + bricks=None, interval_check=120): """Monitors heal completion by looking into .glusterfs/indices/xattrop directory of every brick for certain time. When there are no entries in all the brick directories then heal is successful. Otherwise heal is @@ -150,6 +151,8 @@ def monitor_heal_completion(mnode, volname, timeout_period=1200, bricks=None): Kwargs: bricks : list of bricks to monitor heal, if not provided heal will be monitored on all bricks of volume + interval_check : Time in seconds, for every given interval checks + the heal info, defaults to 120. Return: bool: True if heal is complete within timeout_period. False otherwise @@ -181,8 +184,8 @@ def monitor_heal_completion(mnode, volname, timeout_period=1200, bricks=None): if heal_complete: break else: - time.sleep(120) - time_counter = time_counter - 120 + time.sleep(interval_check) + time_counter = time_counter - interval_check if heal_complete and bricks: # In EC volumes, check heal completion only on online bricks -- cgit