]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa: add debug information for client address for kclient
authorXiubo Li <xiubli@redhat.com>
Mon, 16 Nov 2020 05:33:46 +0000 (13:33 +0800)
committerXiubo Li <xiubli@redhat.com>
Tue, 17 Nov 2020 01:44:57 +0000 (09:44 +0800)
Fixes: https://tracker.ceph.com/issues/48242
Signed-off-by: Xiubo Li <xiubli@redhat.com>
qa/tasks/cephfs/kernel_mount.py
qa/tasks/cephfs/mount.py

index dc36384e3f4b14e3a619a6a5a29b2d8a7bad9823..03ab3ddaaa861939e97f244bbeaa8db4c34734de 100644 (file)
@@ -1,5 +1,6 @@
 import json
 import logging
+import re
 
 from io import StringIO
 from textwrap import dedent
@@ -26,6 +27,8 @@ class KernelMount(CephFSMount):
             cephfs_name=cephfs_name, cephfs_mntpt=cephfs_mntpt, brxnet=brxnet)
 
         self.rbytes = config.get('rbytes', False)
+        self.inst = None
+        self.addr = None
 
     def mount(self, mntopts=[], createfs=True, check_status=True, **kwargs):
         self.update_attrs(**kwargs)
@@ -233,6 +236,44 @@ class KernelMount(CephFSMount):
         lines = mds_sessions.split("\n")
         return int(lines[0].split()[1])
 
+    @property
+    def _global_addr(self):
+        if self.addr is not None:
+            return self.addr
+
+        # The first line of the "status" file's output will be something
+        # like:
+        #   "instance: client.4297 (0)10.72.47.117:0/1148470933"
+        # What we need here is only the string "10.72.47.117:0/1148470933"
+        status = self.read_debug_file("status")
+        if status is None:
+            return None
+
+        instance = re.findall(r'instance:.*', status)[0]
+        self.addr = instance.split()[2].split(')')[1]
+        return self.addr;
+
+    @property
+    def _global_inst(self):
+        if self.inst is not None:
+            return self.inst
+
+        client_gid = "client%d" % self.get_global_id()
+        self.inst = " ".join([client_gid, self._global_addr])
+        return self.inst
+
+    def get_global_inst(self):
+        """
+        Look up the CephFS client instance for this mount
+        """
+        return self._global_inst
+
+    def get_global_addr(self):
+        """
+        Look up the CephFS client addr for this mount
+        """
+        return self._global_addr
+
     def get_osd_epoch(self):
         """
         Return 2-tuple of osd_epoch, osd_epoch_barrier
index 0cc86f906a0dc5ca07cf2b2468446fd3f9fd14b3..61fd1574e40e91bb990af091b16241bcac9b05c9 100644 (file)
@@ -563,6 +563,10 @@ class CephFSMount(object):
 
     def is_blocklisted(self):
         addr = self.get_global_addr()
+        if addr is None:
+            log.warn("Couldn't get the client address, so the blocklisted status undetermined")
+            return False
+
         blocklist = json.loads(self.fs.mon_manager.raw_cluster_cmd("osd", "blocklist", "ls", "--format=json"))
         for b in blocklist:
             if addr == b["addr"]: