]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Improve processing of multiple OSD requests
authorTiago Melo <tmelo@suse.com>
Thu, 19 Sep 2019 11:06:10 +0000 (11:06 +0000)
committerTiago Melo <tmelo@suse.com>
Fri, 20 Sep 2019 11:48:18 +0000 (11:48 +0000)
We were not using forkJoin when calling scrub endpoint.

Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-scrub-modal/osd-scrub-modal.component.ts

index a1cd929f0f429b465dc3187176f41c1a8478b806..3605b2d493ef97ecc3ff069719340d7efad5cc41 100644 (file)
@@ -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()
             );
           }
         }
index f25ae21e149764b7af95f541b41dcddd185e1b43..7b859b7398f1ee2e9de793c1fe7b651bd4277473 100644 (file)
@@ -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()
+    );
   }
 }