From: Guillaume Abrioux Date: Thu, 7 Oct 2021 08:49:25 +0000 (+0200) Subject: cephadm: shell --mount shouldnt enforce ':z' option X-Git-Tag: v17.1.0~718^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=aeae360e2595f348f10ddc36cdb270b018f7eb02;p=ceph.git cephadm: shell --mount shouldnt enforce ':z' option 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 --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 17b7fcfc333a..fd64aef1129e 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -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: diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py index 95ca034c0c0d..d95f76ea1b8f 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -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):