From de1e0ccd7a6c065ab2df7d3a108f4132f3942c41 Mon Sep 17 00:00:00 2001 From: Avan Thakkar Date: Tue, 8 Jun 2021 20:04:00 +0530 Subject: [PATCH] mgr/dashboard: crushmap tree doesn't display crush type other than root Fixes: https://tracker.ceph.com/issues/50971 Signed-off-by: Avan Thakkar --- qa/tasks/mgr/dashboard/test_crush_rule.py | 3 ++- src/pybind/mgr/dashboard/controllers/crush_rule.py | 6 +++++- .../app/ceph/cluster/crushmap/crushmap.component.spec.ts | 9 +++++---- .../src/app/ceph/cluster/crushmap/crushmap.component.ts | 3 ++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/qa/tasks/mgr/dashboard/test_crush_rule.py b/qa/tasks/mgr/dashboard/test_crush_rule.py index 30ce834a5b780..1e37553b24a00 100644 --- a/qa/tasks/mgr/dashboard/test_crush_rule.py +++ b/qa/tasks/mgr/dashboard/test_crush_rule.py @@ -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) })) diff --git a/src/pybind/mgr/dashboard/controllers/crush_rule.py b/src/pybind/mgr/dashboard/controllers/crush_rule.py index 7b0c17fde07f4..13986f3841321 100644 --- a/src/pybind/mgr/dashboard/controllers/crush_rule.py +++ b/src/pybind/mgr/dashboard/controllers/crush_rule.py @@ -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() } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.spec.ts index bed73b5ff53ca..2fc0c141e6fa6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.spec.ts @@ -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: [ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts index c44dad3f25e07..e3a9ce5780f4c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts @@ -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); -- 2.39.5