]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-volume util.prepare allow and dedupe extra flags for mounting
authorAlfredo Deza <adeza@redhat.com>
Mon, 16 Apr 2018 16:44:24 +0000 (12:44 -0400)
committerAlfredo Deza <adeza@redhat.com>
Tue, 17 Apr 2018 18:37:02 +0000 (14:37 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/util/prepare.py

index e57dc145d8ef71dbe0571f082cb5ff1c680ad23d..2cc653c78c1e191b3e0a38e76e4bf8e7d6b2fa37 100644 (file)
@@ -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)