]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/mirroring: throttle directory reassigment to mirror daemons
authorVenky Shankar <vshankar@redhat.com>
Sun, 1 Aug 2021 14:21:46 +0000 (10:21 -0400)
committerVenky Shankar <vshankar@redhat.com>
Tue, 9 Nov 2021 05:08:05 +0000 (00:08 -0500)
This is to avoid over-shuffling directories when lots of mirror
daemons come and go.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/pybind/mgr/mirroring/fs/dir_map/policy.py

index 608a92bf541bfaf014901eeb27813d5a19929f83..aef90b55fe5f4afedfeb704754a691a599da077a 100644 (file)
@@ -27,6 +27,10 @@ class DirectoryState:
             f' purging={self.purging}]'
 
 class Policy:
+    # number of seconds after which a directory can be reshuffled
+    # to other mirror daemon instances.
+    DIR_SHUFFLE_THROTTLE_INTERVAL = 300
+
     def __init__(self):
         self.dir_states = {}
         self.instance_to_dir_map = {}
@@ -54,7 +58,8 @@ class Policy:
         """
         log.debug(f'can_shuffle_dir: {dir_path}')
         dir_state = self.dir_states[dir_path]
-        return StateTransition.is_idle(dir_state.state)
+        return StateTransition.is_idle(dir_state.state) and \
+            (time.time() - dir_state['mapped_time']) > Policy.DIR_SHUFFLE_THROTTLE_INTERVAL
 
     def set_state(self, dir_state, state, ignore_current_state=False):
         if not ignore_current_state and dir_state.state == state: