]> git.apps.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)
committerSebastian Wagner <sewagner@redhat.com>
Tue, 2 Nov 2021 09:01:20 +0000 (10:01 +0100)
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>
(cherry picked from commit aeae360e2595f348f10ddc36cdb270b018f7eb02)

src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index 7e367993ec70e25fd6fc237f392e8c9341ed721f..20627916844c16f2173aea9d34e74597f588b515 100755 (executable)
@@ -4638,10 +4638,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 4c8f573d0f6bfad11a995ba675e684dc582ef70e..c4c902a68b5df66d1f0e7b2e17592e942fb631a2 100644 (file)
@@ -1384,6 +1384,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):