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')
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):
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.
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):
"""
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):
"""
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)
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)
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()
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__)
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: