]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: make --journal optional, add --journal-slots
authorJan Fajerski <jfajerski@suse.com>
Mon, 7 Sep 2020 12:54:01 +0000 (14:54 +0200)
committerJan Fajerski <jfajerski@suse.com>
Fri, 25 Sep 2020 09:50:23 +0000 (11:50 +0200)
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
src/ceph-volume/ceph_volume/devices/lvm/batch.py
src/ceph-volume/ceph_volume/devices/lvm/common.py
src/ceph-volume/ceph_volume/devices/lvm/prepare.py

index 78b323cc1f5f13f51b90dd52a178b52ee88850ea..a26c965db9a5de272d5fabbf981a6cfdc052b019 100644 (file)
@@ -276,9 +276,14 @@ class Batch(object):
             type=int,
             help='Provision slots on WAL device, can remain unoccupied'
         )
+        def journal_size_in_mb_hack(size):
+            # give user time to adjust, then remove here
+            if size and size[-1].isdigit():
+                size += 'M'
+            return disk.Size.parse(size)
         parser.add_argument(
             '--journal-size',
-            type=disk.Size.parse,
+            type=journal_size_in_mb_hack,
             help='Override the "osd_journal_size" value, in megabytes'
         )
         parser.add_argument(
index e8d976540b3a8c9e2145c56db7f639526c660d36..2ad8562ae61d7dd40ac231e24cac7745ee9e5fff 100644 (file)
@@ -128,13 +128,19 @@ filestore_args = {
         'help': 'Use the filestore objectstore',
     },
     '--journal': {
-        'help': '(REQUIRED) A logical volume (vg_name/lv_name), or path to a device',
+        'help': 'A logical volume (vg_name/lv_name), or path to a device',
     },
     '--journal-size': {
         'help': 'Size of journal LV in case a raw block device was passed in --journal',
         'default': '0',
         'type': disk.Size.parse
     },
+    '--journal-slots': {
+        'help': ('Intended number of slots on journal device. The new OSD gets one'
+              'of those slots or 1/nth of the available capacity'),
+        'type': int,
+        'default': 1,
+    },
 }
 
 def get_default_args():
index a951546a879a7e8e7a8c13eab7251fe578407c32..fe1132dd5b81abcb89f5425b5220d5dbe01c95c4 100644 (file)
@@ -135,7 +135,7 @@ class Prepare(object):
             raise RuntimeError('unable to use device')
         return uuid
 
-    def setup_device(self, device_type, device_name, tags, size):
+    def setup_device(self, device_type, device_name, tags, size, slots):
         """
         Check if ``device`` is an lv, if so, set the tags, making sure to
         update the tags with the lv_uuid and lv_path which the incoming tags
@@ -170,9 +170,7 @@ class Prepare(object):
             kwargs = {
                 'device': device_name,
                 'tags': tags,
-                'slots': getattr(self.args,
-                                 'block_{}_slots'.format(device_type),
-                                 1),
+                'slots': slots
             }
             #TODO use get_block_db_size and co here to get configured size in
             #conf file
@@ -302,7 +300,28 @@ class Prepare(object):
             #TODO: allow auto creation of journal on passed device, only works
             # when physical device is passed, not LV
             if not self.args.journal:
-                raise RuntimeError('--journal is required when using --filestore')
+                logger.info(('no journal was specifed, creating journal lv '
+                            'on {}').format(self.args.data))
+                self.args.journal = self.args.data
+                self.args.journal_size = disk.Size(g=5)
+                # need to adjust data size/slots for colocated journal
+                if self.args.data_size:
+                    self.args.data_size -= self.args.journal_size
+                if self.args.data_slots == 1:
+                    self.args.data_slots = 0
+                else:
+                    raise RuntimeError(('Can\'t handle multiple filestore OSDs '
+                                       'with colocated journals yet. Please '
+                                       'create journal LVs manually'))
+            tags['ceph.cephx_lockbox_secret'] = cephx_lockbox_secret
+            tags['ceph.encrypted'] = encrypted
+
+            journal_device, journal_uuid, tags = self.setup_device(
+                'journal',
+                self.args.journal,
+                tags,
+                self.args.journal_size,
+                self.args.journal_slots)
 
             try:
                 vg_name, lv_name = self.args.data.split('/')
@@ -316,15 +335,13 @@ class Prepare(object):
 
             tags['ceph.data_device'] = data_lv.lv_path
             tags['ceph.data_uuid'] = data_lv.lv_uuid
-            tags['ceph.cephx_lockbox_secret'] = cephx_lockbox_secret
-            tags['ceph.encrypted'] = encrypted
             tags['ceph.vdo'] = api.is_vdo(data_lv.lv_path)
-
-            journal_device, journal_uuid, tags = self.setup_device(
-                'journal', self.args.journal, tags, self.args.journal_size)
-
             tags['ceph.type'] = 'data'
             data_lv.set_tags(tags)
+            if not journal_device.startswith('/'):
+                # we got a journal lv, set rest of the tags
+                api.get_first_lv(filters={'lv_name': lv_name,
+                                          'vg_name': vg_name}).set_tags(tags)
 
             prepare_filestore(
                 data_lv.lv_path,
@@ -352,9 +369,17 @@ class Prepare(object):
             tags['ceph.vdo'] = api.is_vdo(block_lv.lv_path)
 
             wal_device, wal_uuid, tags = self.setup_device(
-                'wal', self.args.block_wal, tags, self.args.block_wal_size)
+                'wal',
+                self.args.block_wal,
+                tags,
+                self.args.block_wal_size,
+                self.args.block_wal_slots)
             db_device, db_uuid, tags = self.setup_device(
-                'db', self.args.block_db, tags, self.args.block_db_size)
+                'db',
+                self.args.block_db,
+                tags,
+                self.args.block_db_size,
+                self.args.block_db_slots)
 
             tags['ceph.type'] = 'block'
             block_lv.set_tags(tags)