From abe7c86337751cf279874869dabbfac8ee8593d8 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 5 Jan 2021 12:34:00 -0800 Subject: [PATCH] qa: remove ceph file systems on completion So that we can avoid MDS replacement warnings. Fixes: https://tracker.ceph.com/issues/48757 Signed-off-by: Patrick Donnelly --- qa/tasks/ceph.py | 9 ++++++++- qa/tasks/cephfs/filesystem.py | 25 +++++++++++++++++++++---- qa/tasks/mds_thrash.py | 4 +++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/qa/tasks/ceph.py b/qa/tasks/ceph.py index 7685a132f105..e484d9127c80 100644 --- a/qa/tasks/ceph.py +++ b/qa/tasks/ceph.py @@ -415,6 +415,7 @@ def cephfs_setup(ctx, config): fs_configs = cephfs_config.pop('fs', [{'name': 'cephfs'}]) set_allow_multifs = len(fs_configs) > 1 + fss = [] for fs_config in fs_configs: assert isinstance(fs_config, dict) name = fs_config.pop('name') @@ -424,8 +425,14 @@ def cephfs_setup(ctx, config): if set_allow_multifs: fs.set_allow_multifs() set_allow_multifs = False + fss.append(fs) - yield + yield + + for fs in fss: + fs.destroy() + else: + yield @contextlib.contextmanager def watchdog_setup(ctx, config): diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index 8df09412576a..66449bd3e0a5 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -60,6 +60,13 @@ class ObjectNotFound(Exception): def __str__(self): return "Object not found: '{0}'".format(self._object_name) +class FSMissing(Exception): + def __init__(self, ident): + self.ident = ident + + def __str__(self): + return f"File system {self.ident} does not exist in the map" + class FSStatus(object): """ Operations on a snapshot of the FSMap. @@ -109,7 +116,7 @@ class FSStatus(object): for fs in self.map['filesystems']: if fscid is None or fs['id'] == fscid: return fs - raise RuntimeError("FSCID {0} not in map".format(fscid)) + raise FSMissing(fscid) def get_fsmap_byname(self, name): """ @@ -118,7 +125,7 @@ class FSStatus(object): for fs in self.map['filesystems']: if name is None or fs['mdsmap']['fs_name'] == name: return fs - raise RuntimeError("FS {0} not in map".format(name)) + raise FSMissing(name) def get_replays(self, fscid): """ @@ -484,6 +491,12 @@ class Filesystem(MDSCluster): if not hasattr(self._ctx, "filesystem"): self._ctx.filesystem = self + def dead(self): + try: + return not bool(self.get_mds_map()) + except FSMissing: + return True + def get_task_status(self, status_key): return self.mon_manager.get_service_task_status("mds", status_key) @@ -648,8 +661,11 @@ class Filesystem(MDSCluster): self.getinfo(refresh = True) def destroy(self, reset_obj_attrs=True): - log.info('Destroying file system ' + self.name + ' and related ' - 'pools') + log.info(f'Destroying file system {self.name} and related pools') + + if self.dead(): + log.debug('already dead...') + return # make sure no MDSs are attached to given FS. self.mon_manager.raw_cluster_cmd('fs', 'fail', self.name) @@ -728,6 +744,7 @@ class Filesystem(MDSCluster): def _df(self): return json.loads(self.mon_manager.raw_cluster_cmd("df", "--format=json-pretty")) + # may raise FSMissing def get_mds_map(self, status=None): if status is None: status = self.status() diff --git a/qa/tasks/mds_thrash.py b/qa/tasks/mds_thrash.py index 44dceae22879..8c7f3cba5906 100644 --- a/qa/tasks/mds_thrash.py +++ b/qa/tasks/mds_thrash.py @@ -13,7 +13,7 @@ from gevent.event import Event from teuthology import misc as teuthology from tasks import ceph_manager -from tasks.cephfs.filesystem import MDSCluster, Filesystem +from tasks.cephfs.filesystem import MDSCluster, Filesystem, FSMissing from tasks.thrasher import Thrasher log = logging.getLogger(__name__) @@ -122,6 +122,8 @@ class MDSThrasher(Thrasher, Greenlet): def _run(self): try: self.do_thrash() + except FSMissing: + pass except Exception as e: # Log exceptions here so we get the full backtrace (gevent loses them). # Also allow successful completion as gevent exception handling is a broken mess: -- 2.47.3