From 4d50da7629145d40da3a2820c3b5c8cdb2bca33f Mon Sep 17 00:00:00 2001 From: Avan Thakkar Date: Mon, 25 Jul 2022 19:19:22 +0530 Subject: [PATCH] mgr/dashboard: cluster > hosts: host list tables doesn't show all services deployed Fixes: https://tracker.ceph.com/issues/53210 Signed-off-by: Avan Thakkar Service instances was displaying only the ceph services, but with these changes it'll display instances of cephadm services as well. --- .../cypress/integration/cluster/hosts.po.ts | 12 +++++++ .../orchestrator/01-hosts.e2e-spec.ts | 5 +++ .../app/ceph/cluster/hosts/hosts.component.ts | 32 +++++++++++++++---- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.po.ts index 62c1f85432e..b769c880a87 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.po.ts @@ -168,4 +168,16 @@ export class HostsPageHelper extends PageHelper { this.expectTableCount('total', 0); }); } + + checkServiceInstancesExist(hostname: string, instances: string[]) { + this.getTableCell(this.columnIndex.hostname, hostname) + .parent() + .find(`datatable-body-cell:nth-child(${this.columnIndex.services}) .badge`) + .should(($ele) => { + const serviceInstances = $ele.toArray().map((v) => v.innerText); + for (const instance of instances) { + expect(serviceInstances).to.include(instance); + } + }); + } } diff --git a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts.e2e-spec.ts index aca36ade192..bfe181aff61 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts.e2e-spec.ts @@ -82,5 +82,10 @@ describe('Hosts page', () => { const hostname = Cypress._.sample(this.hosts).name; hosts.maintenance(hostname, true); }); + + it('should exit host from maintenance', function () { + const hostname = Cypress._.sample(this.hosts).name; + hosts.checkServiceInstancesExist(hostname, ['mgr: 1', 'prometheus: 1']); + }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts index 60cedf853c9..cabbaec726c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts @@ -3,7 +3,7 @@ import { Router } from '@angular/router'; import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import _ from 'lodash'; -import { Subscription } from 'rxjs'; +import { Observable, Subscription } from 'rxjs'; import { map, mergeMap } from 'rxjs/operators'; import { HostService } from '~/app/shared/api/host.service'; @@ -22,6 +22,7 @@ import { CdTableAction } from '~/app/shared/models/cd-table-action'; import { CdTableColumn } from '~/app/shared/models/cd-table-column'; import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context'; import { CdTableSelection } from '~/app/shared/models/cd-table-selection'; +import { Daemon } from '~/app/shared/models/daemon.interface'; import { FinishedTask } from '~/app/shared/models/finished-task'; import { OrchestratorFeature } from '~/app/shared/models/orchestrator.enum'; import { OrchestratorStatus } from '~/app/shared/models/orchestrator.interface'; @@ -496,12 +497,29 @@ export class HostsComponent extends ListWithDetails implements OnDestroy, OnInit hostList.map((host) => { const counts = {}; host['service_instances'] = new Set(); - host['services'].forEach((service: any) => { - counts[service.type] = (counts[service.type] || 0) + 1; - }); - host['services'].map((service: any) => { - host['service_instances'].add(`${service.type}: ${counts[service.type]}`); - }); + if (this.orchStatus?.available) { + let daemons: Daemon[] = []; + let observable: Observable; + observable = this.hostService.getDaemons(host['hostname']); + observable.subscribe((dmns: Daemon[]) => { + daemons = dmns; + daemons.forEach((daemon: any) => { + counts[daemon.daemon_type] = (counts[daemon.daemon_type] || 0) + 1; + }); + daemons.map((daemon: any) => { + host['service_instances'].add( + `${daemon.daemon_type}: ${counts[daemon.daemon_type]}` + ); + }); + }); + } else { + host['services'].forEach((service: any) => { + counts[service.type] = (counts[service.type] || 0) + 1; + }); + host['services'].map((service: any) => { + host['service_instances'].add(`${service.type}: ${counts[service.type]}`); + }); + } return host; }) ) -- 2.39.5