From: Duanming Zhou Date: Sun, 12 Apr 2026 07:40:40 +0000 (+0000) Subject: ceph-volume: add --osd-fsid support to raw mode prepare X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=272f514df724e1138785751236c788759470d0f8;p=ceph.git ceph-volume: add --osd-fsid support to raw mode prepare 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 --- diff --git a/src/ceph-volume/ceph_volume/devices/raw/common.py b/src/ceph-volume/ceph_volume/devices/raw/common.py index 27a2b67a9c0a..8f8c258a84cd 100644 --- a/src/ceph-volume/ceph_volume/devices/raw/common.py +++ b/src/ceph-volume/ceph_volume/devices/raw/common.py @@ -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', diff --git a/src/ceph-volume/ceph_volume/objectstore/raw.py b/src/ceph-volume/ceph_volume/objectstore/raw.py index 25a577d3f95a..4ff17a699132 100644 --- a/src/ceph-volume/ceph_volume/objectstore/raw.py +++ b/src/ceph-volume/ceph_volume/objectstore/raw.py @@ -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', '')