diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index 226eb02d192..707a531dd98 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -254,6 +254,20 @@ class CephCluster(object): log.debug("_json_asok output empty") return None + def is_addr_blocklisted(self, addr=None): + if addr is None: + log.warn("Couldn't get the client address, so the blocklisted " + "status undetermined") + return False + + blocklist = json.loads(self.mon_manager.run_cluster_cmd( + args=["osd", "blocklist", "ls", "--format=json"], + stdout=StringIO()).stdout.getvalue()) + for b in blocklist: + if addr == b["addr"]: + return True + return False + class MDSCluster(CephCluster): """ diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index 2bf3aec60e1..fabc27fe9cd 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -573,18 +573,6 @@ class CephFSMount(object): finally: self.umount_wait() - 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"]: - return True - return False - def create_file(self, filename='testfile', dirname=None, user=None, check_status=True): assert(self.is_mounted()) diff --git a/qa/tasks/cephfs/test_misc.py b/qa/tasks/cephfs/test_misc.py index 6a295bbfdf1..47c3af75a42 100644 --- a/qa/tasks/cephfs/test_misc.py +++ b/qa/tasks/cephfs/test_misc.py @@ -165,7 +165,8 @@ class TestMisc(CephFSTestCase): cap_waited, session_timeout )) - self.assertTrue(self.mount_a.is_blocklisted()) + self.assertTrue(self.mds_cluster.is_addr_blocklisted( + self.mount_a.get_global_addr())) self.mount_a._kill_background(cap_holder) finally: self.mount_a.resume_netns() diff --git a/qa/tasks/cephfs/test_sessionmap.py b/qa/tasks/cephfs/test_sessionmap.py index 6d37879277f..79f1fb45e24 100644 --- a/qa/tasks/cephfs/test_sessionmap.py +++ b/qa/tasks/cephfs/test_sessionmap.py @@ -192,7 +192,8 @@ class TestSessionMap(CephFSTestCase): Check that mds evicts blocklisted client """ if not isinstance(self.mount_a, FuseMount): - self.skipTest("Requires FUSE client to use is_blocklisted()") + self.skipTest("Requires FUSE client to use " + "mds_cluster.is_addr_blocklisted()") self.fs.set_max_mds(2) status = self.fs.wait_for_daemons() @@ -213,7 +214,8 @@ class TestSessionMap(CephFSTestCase): mount_a_client_id = self.mount_a.get_global_id() self.fs.mds_asok(['session', 'evict', "%s" % mount_a_client_id], mds_id=self.fs.get_rank(rank=0, status=status)['name']) - self.wait_until_true(lambda: self.mount_a.is_blocklisted(), timeout=30) + self.wait_until_true(lambda: self.mds_cluster.is_addr_blocklisted( + self.mount_a.get_global_addr()), timeout=30) # 10 seconds should be enough for evicting client time.sleep(10) diff --git a/qa/tasks/fs.py b/qa/tasks/fs.py index 4f7a3e2060b..b4f3e3a1607 100644 --- a/qa/tasks/fs.py +++ b/qa/tasks/fs.py @@ -56,10 +56,10 @@ def clients_evicted(ctx, config): if mount is not None: if evicted: log.info("confirming client {} is blocklisted".format(client)) - assert mount.is_blocklisted() + assert fs.is_addr_blocklisted(mount.get_global_addr()) elif client in no_session: log.info("client {} should not be evicted but has no session with an MDS".format(client)) - mount.is_blocklisted() # for debugging + fs.is_addr_blocklisted(mount.get_global_addr()) # for debugging should_assert = True if should_assert: raise RuntimeError("some clients which should not be evicted have no session with an MDS?")