From cbbb15fb35050677169085a93c6ce62f39b84ecb Mon Sep 17 00:00:00 2001 From: Leonid Chernin Date: Thu, 19 Dec 2024 09:29:37 +0000 Subject: [PATCH] add debug logs to rebalance Signed-off-by: Leonid Chernin --- control/rebalance.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/control/rebalance.py b/control/rebalance.py index 608fb850..59e6b211 100755 --- a/control/rebalance.py +++ b/control/rebalance.py @@ -16,7 +16,7 @@ from .utils import GatewayLogger from .config import GatewayConfig from .proto import gateway_pb2 as pb2 - +MIN_LOAD = 2000 class Rebalance: """Miscellaneous functions which do rebalance of ANA groups """ @@ -49,22 +49,27 @@ def auto_rebalance_task(self, death_event): time.sleep(self.rebalance_period_sec) def find_min_loaded_group(self, grp_list)->int: - min_load = 2000 + min_load = MIN_LOAD chosen_ana_group = 0 + chosen_nqn = "null" for ana_grp in self.gw_srv.ana_grp_ns_load : if ana_grp in grp_list : + self.logger.debug(f" ana-group {ana_grp} total load {self.gw_srv.ana_grp_ns_load[ana_grp]}") if self.gw_srv.ana_grp_ns_load[ana_grp] <= min_load: min_load = self.gw_srv.ana_grp_ns_load[ana_grp] chosen_ana_group = ana_grp - min_load = 2000 - for nqn in self.gw_srv.ana_grp_subs_load[chosen_ana_group] : - if self.gw_srv.ana_grp_subs_load[chosen_ana_group][nqn] < min_load: - min_load = self.gw_srv.ana_grp_subs_load[chosen_ana_group][nqn] - chosen_nqn = nqn + min_load = MIN_LOAD + self.logger.debug(f"chosen ana-group {chosen_ana_group}") + if chosen_ana_group != 0 : + for nqn in self.gw_srv.ana_grp_subs_load[chosen_ana_group] : + self.logger.debug(f"chosen ana-group {chosen_ana_group} nqn {nqn} load {self.gw_srv.ana_grp_subs_load[chosen_ana_group][nqn]}") + if self.gw_srv.ana_grp_subs_load[chosen_ana_group][nqn] < min_load: + min_load = self.gw_srv.ana_grp_subs_load[chosen_ana_group][nqn] + chosen_nqn = nqn return chosen_ana_group, chosen_nqn def find_min_loaded_group_in_subsys(self, nqn, grp_list)->int: - min_load = 2000 + min_load = MIN_LOAD chosen_ana_group = 0 for ana_grp in grp_list : if self.gw_srv.ana_grp_ns_load[ana_grp] == 0: