From: Venky Shankar Date: Sun, 1 Aug 2021 14:21:46 +0000 (-0400) Subject: mgr/mirroring: throttle directory reassigment to mirror daemons X-Git-Tag: v17.1.0~468^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e253f685382efd7fa82849fb5eb4ad803099ca73;p=ceph-ci.git mgr/mirroring: throttle directory reassigment to mirror daemons This is to avoid over-shuffling directories when lots of mirror daemons come and go. Signed-off-by: Venky Shankar --- diff --git a/src/pybind/mgr/mirroring/fs/dir_map/policy.py b/src/pybind/mgr/mirroring/fs/dir_map/policy.py index 608a92bf541..aef90b55fe5 100644 --- a/src/pybind/mgr/mirroring/fs/dir_map/policy.py +++ b/src/pybind/mgr/mirroring/fs/dir_map/policy.py @@ -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: