Skip to content

Commit

Permalink
perform auto rebalance from the separate thread,
Browse files Browse the repository at this point in the history
merged with last  devel branch
  • Loading branch information
Leonid Chernin committed Nov 3, 2024
1 parent 32e9519 commit 45ac9cf
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions control/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 45ac9cf

Please sign in to comment.