]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: move is_blocklisted() to filesystem.CephCluster 39814/head
authorRishabh Dave <ridave@redhat.com>
Wed, 3 Mar 2021 11:44:22 +0000 (17:14 +0530)
committerRishabh Dave <ridave@redhat.com>
Sat, 6 Mar 2021 03:41:36 +0000 (09:11 +0530)
Using self.fs.mon_manager in mount.py can lead to a crash since self.fs
can be None. Move is_blocklisted() to tasks.filesystem.CephCluster where
it can get access to mon_manager without depending on objects
representing Ceph FSs.

Fixes: https://tracker.ceph.com/issues/49511
Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/cephfs/filesystem.py
qa/tasks/cephfs/mount.py
qa/tasks/cephfs/test_misc.py
qa/tasks/cephfs/test_sessionmap.py
qa/tasks/fs.py

index 226eb02d1922d94462c9855c3f87c7464d014674..707a531dd98fdf5a58fe2180183101f831990a81 100644 (file)
@@ -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):
     """
index 2bf3aec60e10ec19fdbc82f4710496cc58383398..fabc27fe9cdcd8be7fc8a9e1ba61364fecd8213a 100644 (file)
@@ -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())
index 6a295bbfdf1aca7dcf442385b994c1e3e4e69c6e..47c3af75a425ac46a609c0bdcb65e48cdf93f8d8 100644 (file)
@@ -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()
index 6d37879277f8ac29b3140e56f5c82880e6d7c018..79f1fb45e243a05f57a32b30c0b464f6de2f80cf 100644 (file)
@@ -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)
index 4f7a3e2060b6cb7525a7fdc59ed9dc7448640b67..b4f3e3a16071a7da18cb0fbc1eb3b5b68ebbf8e2 100644 (file)
@@ -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?")