From 81c20e6b58b77671ffaa0f8030f18747e1a23569 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Mon, 16 Apr 2018 12:44:24 -0400 Subject: [PATCH] ceph-volume util.prepare allow and dedupe extra flags for mounting Signed-off-by: Alfredo Deza --- src/ceph-volume/ceph_volume/util/prepare.py | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/ceph-volume/ceph_volume/util/prepare.py b/src/ceph-volume/ceph_volume/util/prepare.py index e57dc145d8e..2cc653c78c1 100644 --- a/src/ceph-volume/ceph_volume/util/prepare.py +++ b/src/ceph-volume/ceph_volume/util/prepare.py @@ -166,20 +166,27 @@ def _normalize_mount_flags(flags, extras=None): if extras: flags.extend(extras) # ensure that spaces and commas are removed so that they can join - # correctly - return ','.join([f.strip().strip(',') for f in flags if f]) + # correctly, remove duplicates + flags = set([f.strip().strip(',') for f in flags if f]) + return ','.join(flags) # split them, clean them, and join them back again flags = flags.strip().split(' ') if extras: flags.extend(extras) - return ','.join( - [f.strip().strip(',') for f in flags if f] - ) + + # remove possible duplicates + flags = ','.join([f.strip().strip(',') for f in flags if f]) + # Before returning, split them again, since strings can be mashed up + # together, preventing removal of duplicate entries + return ','.join(set(flags.split(','))) def mount_osd(device, osd_id, **kw): - is_vdo = kw.get('is_vdo', 0) + extras = [] + is_vdo = kw.get('is_vdo', '0') + if is_vdo == '1': + extras = ['discard'] destination = '/var/lib/ceph/osd/%s-%s' % (conf.cluster, osd_id) command = ['mount', '-t', 'xfs', '-o'] flags = conf.ceph.get_list( @@ -188,7 +195,9 @@ def mount_osd(device, osd_id, **kw): default=constants.mount.get('xfs'), split=' ', ) - command.append(_normalize_mount_flags(flags)) + command.append( + _normalize_mount_flags(flags, extras=extras) + ) command.append(device) command.append(destination) process.run(command) -- 2.39.5