From 6b1c6cd8973ee4fbf4ed6c62934810049bba53be Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Thu, 19 Sep 2019 11:06:10 +0000 Subject: [PATCH] mgr/dashboard: Improve processing of multiple OSD requests We were not using forkJoin when calling scrub endpoint. Signed-off-by: Tiago Melo --- .../osd/osd-list/osd-list.component.ts | 15 ++++---- .../osd-scrub-modal.component.ts | 36 +++++++++---------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts index a1cd929f0f429..3605b2d493ef9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts @@ -300,10 +300,8 @@ export class OsdListComponent implements OnInit { }, onSubmit: () => { observableForkJoin( - this.getSelectedIds().map((osd: any) => { - onSubmit.call(this.osdService, osd).subscribe(() => this.bsModalRef.hide()); - }) - ); + this.getSelectedIds().map((osd: any) => onSubmit.call(this.osdService, osd)) + ).subscribe(() => this.bsModalRef.hide()); } } }); @@ -337,9 +335,12 @@ export class OsdListComponent implements OnInit { }, submitAction: () => { observableForkJoin( - this.getSelectedIds().map((osd: any) => { - action.call(this.osdService, osd).subscribe(() => modalRef.hide()); - }) + this.getSelectedIds().map((osd: any) => action.call(this.osdService, osd)) + ).subscribe( + () => { + modalRef.hide(); + }, + () => modalRef.hide() ); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-scrub-modal/osd-scrub-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-scrub-modal/osd-scrub-modal.component.ts index f25ae21e14976..7b859b7398f1e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-scrub-modal/osd-scrub-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-scrub-modal/osd-scrub-modal.component.ts @@ -3,6 +3,7 @@ import { FormGroup } from '@angular/forms'; import { I18n } from '@ngx-translate/i18n-polyfill'; import { BsModalRef } from 'ngx-bootstrap/modal'; +import { forkJoin } from 'rxjs'; import { OsdService } from '../../../../shared/api/osd.service'; import { NotificationType } from '../../../../shared/enum/notification-type.enum'; @@ -32,24 +33,21 @@ export class OsdScrubModalComponent implements OnInit { } scrub() { - for (const id of this.selected) { - this.osdService.scrub(id, this.deep).subscribe( - () => { - const operation = this.deep ? 'Deep scrub' : 'Scrub'; - - this.notificationService.show( - NotificationType.success, - this.i18n('{{operation}} was initialized in the following OSD(s): {{id}}', { - operation: operation, - id: this.listPipe.transform(this.selected) - }) - ); - this.bsModalRef.hide(); - }, - () => { - this.bsModalRef.hide(); - } - ); - } + forkJoin(this.selected.map((id: any) => this.osdService.scrub(id, this.deep))).subscribe( + () => { + const operation = this.deep ? 'Deep scrub' : 'Scrub'; + + this.notificationService.show( + NotificationType.success, + this.i18n('{{operation}} was initialized in the following OSD(s): {{id}}', { + operation: operation, + id: this.listPipe.transform(this.selected) + }) + ); + + this.bsModalRef.hide(); + }, + () => this.bsModalRef.hide() + ); } } -- 2.39.5