]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: link new OSDs to existing managed services 61209/head
authorKushal Deb <Kushal.Deb@ibm.com>
Wed, 15 Jan 2025 05:13:44 +0000 (10:43 +0530)
committerKushal Deb <Kushal.Deb@ibm.com>
Tue, 25 Feb 2025 16:23:19 +0000 (21:53 +0530)
Added logic for new OSDs to link to existing managed services.
The create_osds function now dynamically assigns service_id based on matching entries in the spec_store.
If no service name is provided, it creates the OSDs with 'osd.default' service
name and they remain unmanaged.

Signed-off-by: Kushal Deb <Kushal.Deb@ibm.com>
doc/cephadm/services/osd.rst
qa/suites/orch/cephadm/smoke-small/start.yaml
qa/suites/orch/cephadm/smoke/start.yaml
qa/suites/orch/cephadm/upgrade/4-wait.yaml
src/pybind/mgr/cephadm/module.py

index bb461478e56fa67df7b7ddcce4e2bffa9c6684e2..97d0b1449033b91466b00297f952d132799b7d77 100644 (file)
@@ -199,17 +199,19 @@ There are multiple ways to create new OSDs:
 
 .. 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
 -------
index 7d89f23d3f85e7c64a63411305ad30f939cfb9c2..ced1a553ec88af32f0a37b0cbfefea64f37210ea 100644 (file)
@@ -20,4 +20,4 @@ tasks:
       - ceph orch host ls
       - ceph orch device ls
       - ceph orch ls --format yaml
-      - ceph orch ls | grep '^osd '
+      - ceph orch ls | grep 'osd'
index 9c413a61d40a0dd9f7aa943fc5f22c9cf0424752..396e29ed98cb72a96557b0e8d0f0d8cc18643dc0 100644 (file)
@@ -25,4 +25,4 @@ tasks:
       - ceph orch host ls
       - ceph orch device ls
       - ceph orch ls --format yaml
-      - ceph orch ls | grep '^osd '
+      - ceph orch ls | grep 'osd'
index 4010c58ed77965295708fa5a04fc604bcc5b1722..16dded25856c32a4348f5aa9af85abaf01d43d32 100644 (file)
@@ -13,4 +13,4 @@ tasks:
       - ceph health detail
       - ceph versions | jq -e '.overall | length == 1'
       - ceph versions | jq -e '.overall | keys' | grep $sha1
-      - ceph orch ls | grep '^osd '
+      - ceph orch ls | grep 'osd'
index f1775da3c210660670b79d2a81cc3c5b55f3010e..0adf88bdb0b9e0a43dc113ebd9226e78f47ed31d 100644 (file)
@@ -42,6 +42,7 @@ from ceph.deployment.service_spec import (
     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
@@ -2867,12 +2868,44 @@ Then run the following:
         """
         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,