]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: shell --mount shouldnt enforce ':z' option
authorGuillaume Abrioux <gabrioux@redhat.com>
Thu, 7 Oct 2021 08:49:25 +0000 (10:49 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Thu, 7 Oct 2021 12:26:06 +0000 (14:26 +0200)
cephadm shouldn't enforce this option.
For instance, it can be an issue when you try to bindmount a file in /usr

Fixes: https://tracker.ceph.com/issues/52853
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index 17b7fcfc333a59fba1c17945e324e5671e479bdf..fd64aef1129e74244316d9cbe119f13a35363574 100755 (executable)
@@ -4884,10 +4884,12 @@ def command_shell(ctx):
             mount = pathify(split_src_dst[0])
             filename = os.path.basename(split_src_dst[0])
             if len(split_src_dst) > 1:
-                dst = split_src_dst[1] + ':z' if len(split_src_dst) == 3 else split_src_dst[1]
+                dst = split_src_dst[1]
+                if len(split_src_dst) == 3:
+                    dst = '{}:{}'.format(dst, split_src_dst[2])
                 mounts[mount] = dst
             else:
-                mounts[mount] = '/mnt/{}:z'.format(filename)
+                mounts[mount] = '/mnt/{}'.format(filename)
     if ctx.command:
         command = ctx.command
     else:
index 95ca034c0c0dcda5fa751289ecd2b98a13552449..d95f76ea1b8f4f7be059f9c1e6a6e87d75b1d0ad 100644 (file)
@@ -1111,6 +1111,29 @@ class TestShell(object):
             assert retval == 0
             assert ctx.keyring == 'foo'
 
+    @mock.patch('cephadm.CephContainer')
+    def test_mount_no_dst(self, m_ceph_container, cephadm_fs):
+        cmd = ['shell', '--mount', '/etc/foo']
+        with with_cephadm_ctx(cmd) as ctx:
+            retval = cd.command_shell(ctx)
+            assert retval == 0
+            assert m_ceph_container.call_args.kwargs['volume_mounts']['/etc/foo'] == '/mnt/foo'
+
+    @mock.patch('cephadm.CephContainer')
+    def test_mount_with_dst_no_opt(self, m_ceph_container, cephadm_fs):
+        cmd = ['shell', '--mount', '/etc/foo:/opt/foo/bar']
+        with with_cephadm_ctx(cmd) as ctx:
+            retval = cd.command_shell(ctx)
+            assert retval == 0
+            assert m_ceph_container.call_args.kwargs['volume_mounts']['/etc/foo'] == '/opt/foo/bar'
+
+    @mock.patch('cephadm.CephContainer')
+    def test_mount_with_dst_and_opt(self, m_ceph_container, cephadm_fs):
+        cmd = ['shell', '--mount', '/etc/foo:/opt/foo/bar:Z']
+        with with_cephadm_ctx(cmd) as ctx:
+            retval = cd.command_shell(ctx)
+            assert retval == 0
+            assert m_ceph_container.call_args.kwargs['volume_mounts']['/etc/foo'] == '/opt/foo/bar:Z'
 
 class TestCephVolume(object):