From: Leonid Usov Date: Thu, 15 Feb 2024 17:16:53 +0000 (+0200) Subject: pybind/mgr: correct type hints for `get_quiesce_leader_info` X-Git-Tag: v19.1.0~203^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=042ff8e8a2b2eddc4adef8ad48b666719d84a078;p=ceph.git pybind/mgr: correct type hints for `get_quiesce_leader_info` Signed-off-by: Leonid Usov (cherry picked from commit 12d687bd4447687f34a43f637f16af72131189da) --- diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 888345c24251..84a86920f79a 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -1752,8 +1752,8 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin): } MDS_STATE_ACTIVE_ORD = MDS_STATE_ORD["up:active"] - def get_quiesce_leader_info(self, fscid: str) -> dict: - leader_info = None + def get_quiesce_leader_info(self, fscid: str) -> Optional[dict]: + leader_info: Optional[dict] = None for fs in self.get("fs_map")['filesystems']: if fscid != fs["id"]: @@ -1772,16 +1772,16 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin): leader_info = info elif info['rank'] == leader_info['rank']: state_ord = self.MDS_STATE_ORD.get(info['state']) - leader_state_ord = self.MDS_STATE_ORD.get(leader_info['state']) - - if state_ord == self.MDS_STATE_ACTIVE_ORD and state_ord > leader_state_ord: + # if there are more than one daemons with the same rank + # only one of them can be active + if state_ord == self.MDS_STATE_ACTIVE_ORD: leader_info = info break return leader_info - def tell_quiesce_leader(self, fscid: str, cmd_dict: dict, inbuf: Optional[str] = None) -> Tuple[int, str, str]: - qleader: dict = self.get_quiesce_leader_info(fscid) + def tell_quiesce_leader(self, fscid: str, cmd_dict: dict) -> Tuple[int, str, str]: + qleader = self.get_quiesce_leader_info(fscid) if qleader is None: self.log.warn("Couldn't resolve the quiesce leader for fscid %s" % fscid) return (-errno.ENOENT, "", "Couldn't resolve the quiesce leader for fscid %s" % fscid)