Skip to content

Commit 7752d87

Browse files
authored
Merge pull request ceph#46201 from rhcs-dashboard/daemon_count_hosts
mgr/dashboard: show daemon count instead of services in host page Reviewed-by: Aashish Sharma <[email protected]> Reviewed-by: Avan Thakkar <[email protected]> Reviewed-by: Ernesto Puerta <[email protected]> Reviewed-by: Pere Diaz Bou <[email protected]> Reviewed-by: sunilangadi2 <NOT@FOUND>
2 parents e24adc9 + ee78b47 commit 7752d87

File tree

5 files changed

+62
-51
lines changed

5 files changed

+62
-51
lines changed

src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.e2e-spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,5 @@ describe('Hosts page', () => {
3131
it('should check at least one host is present', () => {
3232
hosts.check_for_host();
3333
});
34-
35-
it('should check services link(s) work for first host', () => {
36-
hosts.check_services_links();
37-
});
3834
});
3935
});

src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.po.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,6 @@ export class HostsPageHelper extends PageHelper {
1919
this.getTableCount('total').should('not.be.eq', 0);
2020
}
2121

22-
// function that checks all services links work for first
23-
// host in table
24-
check_services_links() {
25-
// check that text (links) is present in services box
26-
let links_tested = 0;
27-
28-
cy.get('cd-hosts a.service-link')
29-
.should('have.length.greaterThan', 0)
30-
.then(($elems) => {
31-
$elems.each((_i, $el) => {
32-
// click link, check it worked by looking for changed breadcrumb,
33-
// navigate back to hosts page, repeat until all links checked
34-
cy.contains('a', $el.innerText).should('exist').click();
35-
this.expectBreadcrumbText('Performance Counters');
36-
this.navigateTo();
37-
links_tested++;
38-
});
39-
// check if any links were actually tested
40-
expect(links_tested).gt(0);
41-
});
42-
}
43-
4422
add(hostname: string, exist?: boolean, maintenance?: boolean, labels: string[] = []) {
4523
cy.get(`${this.pages.add.id}`).within(() => {
4624
cy.get('#hostname').type(hostname);

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,9 @@
4747

4848
<ng-template #servicesTpl
4949
let-value="value">
50-
<span *ngFor="let service of value; last as isLast">
51-
<a class="service-link"
52-
[routerLink]="[service.cdLink]"
53-
[queryParams]="cdParams"
54-
*ngIf="service.canRead">{{ service.type }}.{{ service.id }}</a>
55-
<span *ngIf="!service.canRead">
56-
{{ service.type }}.{{ service.id }}
57-
</span>
58-
<ng-container *ngIf="!isLast">, </ng-container>
50+
<span *ngFor="let instance of value; last as isLast">
51+
<span class="badge badge-background-primary" >{{ instance }}</span>
52+
<ng-container *ngIf="!isLast">&nbsp;</ng-container>
5953
</span>
6054
</ng-template>
6155

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,56 @@ describe('HostsComponent', () => {
117117
expect(spans[0].textContent).toBe(hostname);
118118
});
119119

120+
it('should show the exact count of the repeating daemons', () => {
121+
const hostname = 'ceph.dev';
122+
const payload = [
123+
{
124+
services: [
125+
{
126+
type: 'mgr',
127+
id: 'x'
128+
},
129+
{
130+
type: 'mgr',
131+
id: 'y'
132+
},
133+
{
134+
type: 'osd',
135+
id: '0'
136+
},
137+
{
138+
type: 'osd',
139+
id: '1'
140+
},
141+
{
142+
type: 'osd',
143+
id: '2'
144+
},
145+
{
146+
type: 'rgw',
147+
id: 'rgw'
148+
}
149+
],
150+
hostname: hostname,
151+
labels: ['foo', 'bar']
152+
}
153+
];
154+
155+
OrchestratorHelper.mockStatus(false);
156+
hostListSpy.and.callFake(() => of(payload));
157+
fixture.detectChanges();
158+
159+
component.getHosts(new CdTableFetchDataContext(() => undefined));
160+
fixture.detectChanges();
161+
162+
const spans = fixture.debugElement.nativeElement.querySelectorAll(
163+
'.datatable-body-cell-label span span.badge.badge-background-primary'
164+
);
165+
expect(spans[0].textContent).toContain('mgr: 2');
166+
expect(spans[1].textContent).toContain('osd: 3');
167+
expect(spans[2].textContent).toContain('rgw: 1');
168+
});
169+
120170
it('should test if host facts are tranformed correctly if orch available', () => {
121171
const features = [OrchestratorFeature.HOST_FACTS];
122172
const payload = [

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
197197
flexGrow: 1
198198
},
199199
{
200-
name: $localize`Services`,
201-
prop: 'services',
202-
flexGrow: 2,
200+
name: $localize`Service Instances`,
201+
prop: 'service_instances',
202+
flexGrow: 1,
203203
cellTemplate: this.servicesTpl
204204
},
205205
{
@@ -483,15 +483,6 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
483483
if (this.isLoadingHosts) {
484484
return;
485485
}
486-
const typeToPermissionKey = {
487-
mds: 'cephfs',
488-
mon: 'monitor',
489-
osd: 'osd',
490-
rgw: 'rgw',
491-
'rbd-mirror': 'rbdMirroring',
492-
mgr: 'manager',
493-
'tcmu-runner': 'iscsi'
494-
};
495486
this.isLoadingHosts = true;
496487
this.sub = this.orchService
497488
.status()
@@ -503,11 +494,13 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit
503494
}),
504495
map((hostList: object[]) =>
505496
hostList.map((host) => {
497+
const counts = {};
498+
host['service_instances'] = new Set<string>();
499+
host['services'].forEach((service: any) => {
500+
counts[service.type] = (counts[service.type] || 0) + 1;
501+
});
506502
host['services'].map((service: any) => {
507-
service.cdLink = `/perf_counters/${service.type}/${encodeURIComponent(service.id)}`;
508-
const permission = this.permissions[typeToPermissionKey[service.type]];
509-
service.canRead = permission ? permission.read : false;
510-
return service;
503+
host['service_instances'].add(`${service.type}: ${counts[service.type]}`);
511504
});
512505
return host;
513506
})

0 commit comments

Comments
 (0)