From cf6797828a62fc17547cb356ac7d0779d39ac8fe Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Mon, 16 Nov 2020 13:33:46 +0800 Subject: [PATCH] qa: add debug information for client address for kclient Fixes: https://tracker.ceph.com/issues/48242 Signed-off-by: Xiubo Li --- qa/tasks/cephfs/kernel_mount.py | 41 +++++++++++++++++++++++++++++++++ qa/tasks/cephfs/mount.py | 4 ++++ 2 files changed, 45 insertions(+) diff --git a/qa/tasks/cephfs/kernel_mount.py b/qa/tasks/cephfs/kernel_mount.py index dc36384e3f4..03ab3ddaaa8 100644 --- a/qa/tasks/cephfs/kernel_mount.py +++ b/qa/tasks/cephfs/kernel_mount.py @@ -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 diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index 0cc86f906a0..61fd1574e40 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -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"]: -- 2.39.5