.. warning:: When deploying new OSDs with ``cephadm``, ensure that the ``ceph-osd`` package is not installed on the target host. If it is installed, conflicts may arise in the management and control of the OSD that may lead to errors or unexpected behavior.
-* OSDs created via ``ceph orch daemon add`` are by default not added to the orchestrator's OSD service. To attach an OSD to a different, existing OSD service, issue a command of the following form:
+* New OSDs created using ``ceph orch daemon add osd`` are added under ``osd.default`` as managed OSDs with a valid spec.
- .. prompt:: bash *
+ To attach an existing OSD to a different managed service, ``ceph orch osd set-spec-affinity`` command can be used:
- ceph orch osd set-spec-affinity <service_name> <osd_id(s)>
+ .. prompt:: bash #
+
+ ceph orch osd set-spec-affinity <service_name> <osd_id(s)>
For example:
.. prompt:: bash #
-
- ceph orch osd set-spec-affinity osd.default_drive_group 0 1
+
+ ceph orch osd set-spec-affinity osd.default_drive_group 0 1
Dry Run
-------
MgmtGatewaySpec,
NvmeofServiceSpec,
)
+from ceph.deployment.drive_group import DeviceSelection
from ceph.utils import str_to_datetime, datetime_to_str, datetime_now
from cephadm.serve import CephadmServe
from cephadm.services.cephadmservice import CephadmDaemonDeploySpec
"""
return [self._apply(spec) for spec in specs]
+ def create_osd_default_spec(self, drive_group: DriveGroupSpec) -> None:
+ # Create the default osd and attach a valid spec to it.
+
+ drive_group.unmanaged = False
+
+ host_pattern_obj = drive_group.placement.host_pattern
+ host = str(host_pattern_obj.pattern)
+ device_list = [d.path for d in drive_group.data_devices.paths] if drive_group.data_devices else []
+ devices = [{"path": d} for d in device_list]
+
+ osd_default_spec = DriveGroupSpec(
+ service_id="default",
+ placement=PlacementSpec(host_pattern=host),
+ data_devices=DeviceSelection(paths=devices),
+ unmanaged=False,
+ objectstore="bluestore"
+ )
+
+ self.log.info(f"Creating OSDs with service ID: {drive_group.service_id} on {host}:{device_list}")
+ self.spec_store.save(osd_default_spec)
+ self.apply([osd_default_spec])
+
@handle_orch_error
def create_osds(self, drive_group: DriveGroupSpec) -> str:
hosts: List[HostSpec] = self.inventory.all_specs()
filtered_hosts: List[str] = drive_group.placement.filter_matching_hostspecs(hosts)
if not filtered_hosts:
return "Invalid 'host:device' spec: host not found in cluster. Please check 'ceph orch host ls' for available hosts"
+
+ if not drive_group.service_id:
+ drive_group.service_id = "default"
+
+ if drive_group.service_id not in self.spec_store.all_specs:
+ self.log.info("osd.default does not exist. Creating it now.")
+ self.create_osd_default_spec(drive_group)
+ else:
+ self.log.info("osd.default already exists.")
+
return self.osd_service.create_from_spec(drive_group)
def _preview_osdspecs(self,