diff --git a/control/grpc.py b/control/grpc.py index 01cd9c90..d56e0306 100644 --- a/control/grpc.py +++ b/control/grpc.py @@ -355,6 +355,15 @@ def __init__(self, config: GatewayConfig, gateway_state: GatewayStateHandler, rp self._init_cluster_context() self.subsys_max_ns = {} self.host_info = SubsystemHostAuth() + self.auto_rebalance = threading.Thread(target=self.auto_rebalance_task, daemon=True) + self.auto_rebalance.start() + + def auto_rebalance_task(self ): + """Periodically calls for auto rebalance.""" + if (self.rebalance_period_sec > 0): + while True: + self.rebalance_logic() + time.sleep(self.rebalance_period_sec) def get_directories_for_key_file(self, key_type : str, subsysnqn : str, create_dir : bool = False) -> []: tmp_dirs = [] @@ -1332,7 +1341,7 @@ def rebalance_logic(self): self.logger.info(f"Called rebalance logic") grps_list = self.ceph_utils.get_number_created_gateways(self.gateway_pool, self.gateway_group) if not self.ceph_utils.is_rebalance_supported(): - self.logger.info(f"Auto rebalance is not supported") + self.logger.info(f"Auto rebalance is not supported with the curent ceph version") return for ana_grp in self.ana_grp_state: @@ -3449,10 +3458,6 @@ def get_subsystems_safe(self, request, context): return pb2.subsystems_info(subsystems=subsystems) def get_subsystems(self, request, context): - - self.count += 1 - if( (self.rebalance_period_sec > 0) and self.count % (self.rebalance_period_sec/MONITOR_POLLING_RATE_SEC) == 0 ): - self.rebalance_logic() with self.spdk_rpc_subsystems_lock: return self.get_subsystems_safe(request, context)