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>
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',
@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', '')