]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: crushmap tree doesn't display crush type other than root 41758/head
authorAvan Thakkar <athakkar@localhost.localdomain>
Tue, 8 Jun 2021 14:34:00 +0000 (20:04 +0530)
committerAvan Thakkar <athakkar@localhost.localdomain>
Tue, 8 Jun 2021 14:34:00 +0000 (20:04 +0530)
Fixes: https://tracker.ceph.com/issues/50971
Signed-off-by: Avan Thakkar <athakkar@redhat.com>
qa/tasks/mgr/dashboard/test_crush_rule.py
src/pybind/mgr/dashboard/controllers/crush_rule.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts

index 30ce834a5b780fbcdf06b644789b358f4173cb35..1e37553b24a006991caf3a78d3f95f0a34b4e1e1 100644 (file)
@@ -82,5 +82,6 @@ class CrushRuleTest(DashboardTestCase):
         self.assertStatus(200)
         self.assertSchemaBody(JObj({
             'names': JList(str),
-            'nodes': JList(JObj({}, allow_unknown=True))
+            'nodes': JList(JObj({}, allow_unknown=True)),
+            'roots': JList(int)
         }))
index 7b0c17fde07f417a67413891d993e949ce9c7920..13986f384132122399b4df64f7d97aa7c18536a2 100644 (file)
@@ -54,7 +54,11 @@ class CrushRuleUi(CrushRule):
     @ReadPermission
     def info(self):
         '''Used for crush rule creation modal'''
+        osd_map = mgr.get_osdmap()
+        crush = osd_map.get_crush()
+        crush.dump()
         return {
             'names': [r['rule_name'] for r in mgr.get('osd_map_crush')['rules']],
-            'nodes': mgr.get('osd_map_tree')['nodes']
+            'nodes': mgr.get('osd_map_tree')['nodes'],
+            'roots': crush.find_roots()
         }
index bed73b5ff53cab90002fc164052e632fb127d2ec..2fc0c141e6fa64f7072642ad7a4831f74e101a3d 100644 (file)
@@ -56,10 +56,11 @@ describe('CrushmapComponent', () => {
           { status: 'up', type: 'osd', name: 'osd.0', id: 0 },
           { status: 'down', type: 'osd', name: 'osd.1', id: 1 },
           { status: 'up', type: 'osd', name: 'osd.2', id: 2 },
-          { children: [-4], type: 'root', name: 'default-2', id: -3 },
+          { children: [-4], type: 'datacenter', name: 'site1', id: -3 },
           { children: [4], type: 'host', name: 'my-host-2', id: -4 },
           { status: 'up', type: 'osd', name: 'osd.0-2', id: 4 }
-        ]
+        ],
+        roots: [-1, -3, -6]
       })
     );
     fixture.detectChanges();
@@ -88,8 +89,8 @@ describe('CrushmapComponent', () => {
         ],
         id: component.nodes[0].id,
         status: undefined,
-        type: 'root',
-        name: 'default-2 (root)'
+        type: 'datacenter',
+        name: 'site1 (datacenter)'
       },
       {
         children: [
index c44dad3f25e07f5a80198eb193f61e496bf9ae04..e3a9ce5780f4cc1b9b1a28a825d0168b0981f7e8 100644 (file)
@@ -58,6 +58,7 @@ export class CrushmapComponent implements OnDestroy, OnInit {
 
   private abstractTreeData(data: any): any[] {
     const nodes = data.nodes || [];
+    const rootNodes = data.roots || [];
     const treeNodeMap: { [key: number]: any } = {};
 
     if (0 === nodes.length) {
@@ -70,7 +71,7 @@ export class CrushmapComponent implements OnDestroy, OnInit {
 
     const roots: any[] = [];
     nodes.reverse().forEach((node: any) => {
-      if (node.type === 'root') {
+      if (rootNodes.includes(node.id)) {
         roots.push(node.id);
       }
       treeNodeMap[node.id] = this.generateTreeLeaf(node, treeNodeMap);