]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: correct type hints for `get_quiesce_leader_info`
authorLeonid Usov <leonid.usov@ibm.com>
Thu, 15 Feb 2024 17:16:53 +0000 (19:16 +0200)
committerLeonid Usov <leonid.usov@ibm.com>
Thu, 14 Mar 2024 19:07:52 +0000 (15:07 -0400)
Signed-off-by: Leonid Usov <leonid.usov@ibm.com>
(cherry picked from commit 12d687bd4447687f34a43f637f16af72131189da)

src/pybind/mgr/mgr_module.py

index 888345c242510ab7321645b507392f324fd00f94..84a86920f79ab723083428d9700f9c0840933db0 100644 (file)
@@ -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)