]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/rook: fix orch ls to display OSD info 42997/head
authorJoseph Sawaya <jsawaya@redhat.com>
Mon, 30 Aug 2021 16:00:58 +0000 (12:00 -0400)
committerJoseph Sawaya <jsawaya@redhat.com>
Tue, 31 Aug 2021 19:15:18 +0000 (15:15 -0400)
This commit adds OSDs to the describe_service method in
the RookOrchestrator class to display the information about
running OSDs when a user does `ceph orch ls`.

Signed-off-by: Joseph Sawaya <jsawaya@redhat.com>
src/pybind/mgr/rook/module.py
src/pybind/mgr/rook/rook_cluster.py

index bf6f673b302d9f435bc380b38b3fa0cf995834c7..0b6badcff08b9cca7bc0d3a6a4da94402a33cbd9 100644 (file)
@@ -348,7 +348,19 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
                     size=active,
                     last_refresh=now,
                 )
-
+        if service_type == 'osd' or service_type is None:
+            # OSDs
+            all_osds = self.rook_cluster.get_osds()
+            svc = 'osd'
+            spec[svc] = orchestrator.ServiceDescription(
+                spec=DriveGroupSpec(
+                    service_type='osd',
+                    placement=PlacementSpec(count=len(all_osds), hosts=[osd.metadata.labels['topology-location-host'] for osd in all_osds]),
+                ),
+                size=len(all_osds),
+                last_refresh=now,
+            running= sum(osd.status.phase == 'Running' for osd in all_osds)
+            )
         for dd in self._list_daemons():
             if dd.service_name() not in spec:
                 continue
index 5a13d3929487784f7837d94186901a904baae5e5..2fa86c9138a8f2df28729b05d26d388e5aacdd61 100644 (file)
@@ -703,6 +703,10 @@ class RookCluster(object):
         self.fetcher.fetch()
         return self.fetcher.devices()
         
+    def get_osds(self) -> List:
+        osd_pods: KubernetesResource = KubernetesResource(self.coreV1_api.list_namespaced_pod, namespace='rook-ceph', label_selector='app=rook-ceph-osd')
+        return list(osd_pods.items)
+        
     def get_nfs_conf_url(self, nfs_cluster: str, instance: str) -> Optional[str]:
         #
         # Fetch cephnfs object for "nfs_cluster" and then return a rados://