]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: check for Ceph FS before mounting
authorRishabh Dave <ridave@redhat.com>
Tue, 23 Feb 2021 18:35:48 +0000 (00:05 +0530)
committerYuri Weinstein <yweinste@redhat.com>
Fri, 5 May 2023 19:19:59 +0000 (19:19 +0000)
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 <ridave@redhat.com>
(cherry picked from commit 95eb0043bf1987307cb8a2307d54bf482f6abfae)
(cherry picked from commit a9a29fe98c4c6026dfcab96bc08e455cbb94ad78)

qa/tasks/cephfs/mount.py

index eb1eea3f13ffde9d1a078ab916287fd974fbea13..20eeb45513a826f11b12ef7f28b7bbd05267d5ff 100644 (file)
@@ -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}')