]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: mount kclient using new-style (v2) syntax
authorVenky Shankar <vshankar@redhat.com>
Thu, 11 Nov 2021 04:15:41 +0000 (23:15 -0500)
committerVenky Shankar <vshankar@redhat.com>
Tue, 30 Nov 2021 06:13:34 +0000 (01:13 -0500)
But, do not throw away the old style mount syntax since we would
want to continue testing it since users (scripts) might still be
using it.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
qa/cephfs/mount/kclient/mount-syntax/$ [new file with mode: 0644]
qa/cephfs/mount/kclient/mount-syntax/v1.yaml [new file with mode: 0644]
qa/cephfs/mount/kclient/mount-syntax/v2.yaml [new file with mode: 0644]
qa/tasks/cephfs/kernel_mount.py

diff --git a/qa/cephfs/mount/kclient/mount-syntax/$ b/qa/cephfs/mount/kclient/mount-syntax/$
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/qa/cephfs/mount/kclient/mount-syntax/v1.yaml b/qa/cephfs/mount/kclient/mount-syntax/v1.yaml
new file mode 100644 (file)
index 0000000..84d5d43
--- /dev/null
@@ -0,0 +1,3 @@
+overrides:
+  kclient:
+      syntax: 'v1'
diff --git a/qa/cephfs/mount/kclient/mount-syntax/v2.yaml b/qa/cephfs/mount/kclient/mount-syntax/v2.yaml
new file mode 100644 (file)
index 0000000..ef7d304
--- /dev/null
@@ -0,0 +1,3 @@
+overrides:
+  kclient:
+      syntax: 'v2'
index d8566d7534cc90a60858544c51e569ace49d59cd..ba1ad0f0d1da59bb48e15fb43797a5bcf9f2596d 100644 (file)
@@ -30,6 +30,7 @@ class KernelMount(CephFSMount):
 
         self.dynamic_debug = config.get('dynamic_debug', False)
         self.rbytes = config.get('rbytes', False)
+        self.syntax_style = config.get('syntax', 'v2')
         self.inst = None
         self.addr = None
         self._mount_bin = ['adjust-ulimits', 'ceph-coverage', self.test_dir +\
@@ -43,6 +44,8 @@ class KernelMount(CephFSMount):
 
         if not self.cephfs_mntpt:
             self.cephfs_mntpt = '/'
+        if not self.cephfs_name:
+            self.cephfs_name = 'cephfs'
 
         self._create_mntpt()
 
@@ -77,28 +80,44 @@ class KernelMount(CephFSMount):
                         mountcmd_stderr.getvalue())
         log.info('mount command passed')
 
+    def _make_mount_cmd_old_or_new_style(self):
+        optd = {}
+        mnt_stx = ''
+        if self.syntax_style == 'v1':
+            mnt_stx = f':{self.cephfs_mntpt}'
+            if self.client_id:
+                optd['name'] = self.client_id
+            if self.cephfs_name:
+                optd['mds_namespace'] = self.cephfs_name
+        elif self.syntax_style == 'v2':
+            mnt_stx = f'{self.client_id}@.{self.cephfs_name}={self.cephfs_mntpt}'
+        else:
+            assert 0, f'invalid syntax style: {self.syntax_style}'
+        return (mnt_stx, optd)
+
     def _get_mount_cmd(self, mntopts):
         opts = 'norequire_active_mds'
-        if self.client_id:
-            opts += ',name=' + self.client_id
         if self.client_keyring_path and self.client_id:
             opts += ',secret=' + self.get_key_from_keyfile()
         if self.config_path:
             opts += ',conf=' + self.config_path
-        if self.cephfs_name:
-            opts += ",mds_namespace=" + self.cephfs_name
         if self.rbytes:
             opts += ",rbytes"
         else:
             opts += ",norbytes"
-        if mntopts:
-            opts += ',' + ','.join(mntopts)
 
         mount_cmd = ['sudo'] + self._nsenter_args
-        mount_dev = ':' + self.cephfs_mntpt
-        mount_cmd += self._mount_bin + [mount_dev, self.hostfs_mntpt, '-v',
+        stx_opt = self._make_mount_cmd_old_or_new_style()
+        for opt_name, opt_val in stx_opt[1].items():
+            opts += f',{opt_name}={opt_val}'
+        if mntopts:
+            opts += ',' + ','.join(mntopts)
+        log.info(f'mounting using device: {stx_opt[0]}')
+        # do not fall-back to old-style mount (catch new-style
+        # mount syntax bugs in the kernel).
+        opts += ",nofallback"
+        mount_cmd += self._mount_bin + [stx_opt[0], self.hostfs_mntpt, '-v',
                                         '-o', opts]
-
         return mount_cmd
 
     def umount(self, force=False):