]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: cluster > hosts: host list tables doesn't show all services deployed
authorAvan Thakkar <athakkar@redhat.com>
Mon, 25 Jul 2022 13:49:22 +0000 (19:19 +0530)
committerAvan Thakkar <athakkar@redhat.com>
Tue, 16 Aug 2022 09:53:27 +0000 (15:23 +0530)
Resolves: rhbz#2101771

Fixes: https://tracker.ceph.com/issues/53210
Signed-off-by: Avan Thakkar <athakkar@redhat.com>
Service instances was displaying only the ceph services, but with these changes it'll display instances
of cephadm services as well.

(cherry picked from commit 4d50da7629145d40da3a2820c3b5c8cdb2bca33f)

src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/hosts.po.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/01-hosts.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.ts

index b741749f770a781599aab23d39d37d6a1da879da..2f810788498799024cd25731bb9cd52a7201c0c4 100644 (file)
@@ -168,4 +168,16 @@ export class HostsPageHelper extends PageHelper {
     // in different steps
     this.getTableCell(this.columnIndex.hostname, hostname).click();
   }
+
+  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);
+        }
+      });
+  }
 }
index aca36ade192198a7faef4396c5f47d5b4103da50..bfe181aff6198e9f7aa63848a155562251522445 100644 (file)
@@ -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']);
+    });
   });
 });
index 60cedf853c9ce6037268592c0c9967e88c570f76..cabbaec726cb28f835d634a72004e0d9fa3af78e 100644 (file)
@@ -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<string>();
-            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<Daemon[]>;
+              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;
           })
         )