]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: add --osd-fsid support to raw mode prepare
authorDuanming Zhou <zhouduanming@gmail.com>
Sun, 12 Apr 2026 07:40:40 +0000 (07:40 +0000)
committerGuillaume Abrioux <gabrioux@ibm.com>
Fri, 24 Apr 2026 08:20:20 +0000 (10:20 +0200)
The LVM mode already supports --osd-fsid to allow external tools
(e.g., Kubernetes operators) to pre-register an OSD ID+UUID via
"ceph osd new" and then pass both to ceph-volume, ensuring the
operator retains full control of the OSD ID lifecycle and can
reliably clean up on prepare failure (no orphan OSDs).

The raw mode was missing this support: prepare() unconditionally
called system.generate_uuid(), ignoring any --osd-fsid value.
When an operator pre-registered osd.N with uuid_A and then ran
"ceph-volume raw prepare --osd-id N --dmcrypt", ceph-volume
generated uuid_B internally and called "ceph osd new uuid_B N",
which failed with EINVAL because the ID was already registered
with a different UUID.

This commit:
- Adds --osd-fsid argument to the raw mode argument parser
  (devices/raw/common.py), consistent with the LVM mode.
- Changes raw.prepare() to honor an externally provided osd_fsid,
  falling back to generate_uuid() only when none is given
  (objectstore/raw.py), consistent with the LVM mode.

Signed-off-by: Duanming Zhou <zhouduanming@gmail.com>
src/ceph-volume/ceph_volume/devices/raw/common.py
src/ceph-volume/ceph_volume/objectstore/raw.py

index 27a2b67a9c0a1977744710f331d91523c8718698..8f8c258a84cd624d8ee196f94b7959632958e8a4 100644 (file)
@@ -70,6 +70,11 @@ def create_parser(prog: str, description: str) -> argparse.ArgumentParser:
         default=None,
         type=arg_validators.valid_osd_id,
     )
+    parser.add_argument(
+        '--osd-fsid',
+        help='Reuse an existing OSD fsid',
+        default=None,
+    )
     parser.add_argument(
         '--osd-type',
         dest='osd_type',
index 25a577d3f95a80ca76338b0e574dd421caefc7e2..4ff17a6991320b4737b148efac17d9eafd6eebd1 100644 (file)
@@ -85,7 +85,7 @@ class Raw(BaseObjectStore):
 
     @decorators.needs_root
     def prepare(self) -> None:
-        self.osd_fsid = system.generate_uuid()
+        self.osd_fsid = self.osd_fsid or system.generate_uuid()
         crush_device_class = self.args.crush_device_class
         if self.encrypted and not self.with_tpm:
             self.dmcrypt_key = os.getenv('CEPH_VOLUME_DMCRYPT_SECRET', '')