From: Avan Thakkar Date: Tue, 8 Jun 2021 14:34:00 +0000 (+0530) Subject: mgr/dashboard: crushmap tree doesn't display crush type other than root X-Git-Tag: v16.2.5~37^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e65f6085962745422dffad03ebc4fa7099ba7ae3;p=ceph.git mgr/dashboard: crushmap tree doesn't display crush type other than root Fixes: https://tracker.ceph.com/issues/50971 Signed-off-by: Avan Thakkar (cherry picked from commit de1e0ccd7a6c065ab2df7d3a108f4132f3942c41) --- diff --git a/qa/tasks/mgr/dashboard/test_crush_rule.py b/qa/tasks/mgr/dashboard/test_crush_rule.py index 30ce834a5b7..1e37553b24a 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 ea5096cca0f..73485ac2df1 100644 --- a/src/pybind/mgr/dashboard/controllers/crush_rule.py +++ b/src/pybind/mgr/dashboard/controllers/crush_rule.py @@ -55,7 +55,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 bed73b5ff53..2fc0c141e6f 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 c44dad3f25e..e3a9ce5780f 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);