From a9a29fe98c4c6026dfcab96bc08e455cbb94ad78 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Wed, 24 Feb 2021 00:05:48 +0530 Subject: [PATCH] qa/cephfs: check for Ceph FS before mounting If the given Ceph FS, or the default Ceph FS when no Ceph FS is given, is absent, abort the execution with AsssertionError and an error message. Signed-off-by: Rishabh Dave (cherry picked from commit 95eb0043bf1987307cb8a2307d54bf482f6abfae) --- qa/tasks/cephfs/mount.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index eb1eea3f13ffd..20eeb45513a82 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -123,6 +123,18 @@ class CephFSMount(object): def netns_name(self, name): self._netns_name = name + def assert_that_ceph_fs_exists(self): + output = self.client_remote.run(args='ceph fs ls', stdout=StringIO()).\ + stdout.getvalue() + if self.cephfs_name: + assert self.cephfs_name in output, \ + 'expected ceph fs is not present on the cluster' + log.info(f'Mounting Ceph FS {self.cephfs_name}; just confirmed its presence on cluster') + else: + assert 'No filesystems enabled' not in output, \ + 'ceph cluster has no ceph fs, not even the default ceph fs' + log.info('Mounting default Ceph FS; just confirmed its presence on cluster') + def assert_and_log_minimum_mount_details(self): """ Make sure we have minimum details required for mounting. Ideally, this @@ -136,6 +148,8 @@ class CephFSMount(object): '3. the remote machine where CephFS will be mounted.\n') raise RuntimeError(errmsg) + self.assert_that_ceph_fs_exists() + log.info('Mounting Ceph FS. Following are details of mount; remember ' '"None" represents Python type None -') log.info(f'self.client_remote.hostname = {self.client_remote.hostname}') -- 2.39.5