mirror of
https://github.com/ceph/ceph
synced 2025-01-01 08:32:24 +00:00
qa/cephfs: move is_blocklisted() to filesystem.CephCluster
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>
This commit is contained in:
parent
f11ccd2d60
commit
4d0f56fcc5
@ -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):
|
||||
"""
|
||||
|
@ -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())
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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?")
|
||||
|
Loading…
Reference in New Issue
Block a user