]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/ceph-volume/ceph_volume/util/prepare.py
update sources to 12.2.10
[ceph.git] / ceph / src / ceph-volume / ceph_volume / util / prepare.py
index 687a5892bda9cc06783ec6335c41b42ec31e6b32..3afa061c8859a3527ae4de347b04f3d5b5fc7ffc 100644 (file)
@@ -70,6 +70,41 @@ def get_journal_size(lv_format=True):
     return journal_size
 
 
+def get_block_db_size(lv_format=True):
+    """
+    Helper to retrieve the size (defined in megabytes in ceph.conf) to create
+    the block.db logical volume, it "translates" the string into a float value,
+    then converts that into gigabytes, and finally (optionally) it formats it
+    back as a string so that it can be used for creating the LV.
+
+    :param lv_format: Return a string to be used for ``lv_create``. A 5 GB size
+    would result in '5G', otherwise it will return a ``Size`` object.
+
+    .. note: Configuration values are in bytes, unlike journals which
+             are defined in gigabytes
+    """
+    conf_db_size = None
+    try:
+        conf_db_size = conf.ceph.get_safe('osd', 'bluestore_block_db_size', None)
+    except RuntimeError:
+        logger.exception("failed to load ceph configuration, will use defaults")
+
+    if not conf_db_size:
+        logger.debug(
+            'block.db has no size configuration, will fallback to using as much as possible'
+        )
+        return None
+    logger.debug('bluestore_block_db_size set to %s' % conf_db_size)
+    db_size = disk.Size(b=str_to_int(conf_db_size))
+
+    if db_size < disk.Size(gb=2):
+        mlogger.error('Refusing to continue with configured size for block.db')
+        raise RuntimeError('block.db sizes must be larger than 2GB, detected: %s' % db_size)
+    if lv_format:
+        return '%sG' % db_size.gb.as_int()
+    return db_size
+
+
 def create_id(fsid, json_secrets, osd_id=None):
     """
     :param fsid: The osd fsid to create, always required