]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Fix duplicate error messages 23287/head
authorStephan Müller <smueller@suse.com>
Fri, 27 Jul 2018 14:15:07 +0000 (16:15 +0200)
committerStephan Müller <smueller@suse.com>
Fri, 27 Jul 2018 14:26:59 +0000 (16:26 +0200)
Duplicate error messages currently appear if the task wrapper service is
used. It calls 'notifyTask' on a failed task, this would be fine if
we didn't have the API interceptor, which watches all API requests and
triggers 'notifyTask' itself if an error appears.

Fixes issue #25139

Signed-off-by: Stephan Müller <smueller@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.ts

index 45910cd1905e89b1f8f987a55a948184f1201076..acd09955e7842f8b19ec0ed6fddb2dc7e334066c 100644 (file)
@@ -54,6 +54,7 @@ describe('TaskWrapperService', () => {
       notify = TestBed.get(NotificationService);
       summaryService = TestBed.get(SummaryService);
       spyOn(notify, 'show');
+      spyOn(notify, 'notifyTask').and.stub();
       spyOn(service, '_handleExecutingTasks').and.callThrough();
       spyOn(summaryService, 'addRunningTask').and.callThrough();
     });
@@ -77,7 +78,6 @@ describe('TaskWrapperService', () => {
       spyOn(taskManager, 'subscribe').and.callFake((name, metadata, onTaskFinished) => {
         onTaskFinished();
       });
-      spyOn(notify, 'notifyTask').and.stub();
       callWrapTaskAroundCall(202, 'async').subscribe(null, null, () => (passed = true));
       expect(notify.notifyTask).toHaveBeenCalled();
     });
@@ -87,6 +87,11 @@ describe('TaskWrapperService', () => {
       expect(service._handleExecutingTasks).not.toHaveBeenCalled();
       expect(passed).toBeTruthy();
       expect(summaryService.addRunningTask).not.toHaveBeenCalled();
+      /**
+       * A notification will be raised by the API interceptor.
+       * This resolves this bug https://tracker.ceph.com/issues/25139
+       */
+      expect(notify.notifyTask).not.toHaveBeenCalled();
     });
   });
 });
index bed55d3f608ddcac6971ea7f4ac262a30f790901..7409608fefd23e60f6cac008aac6268dceb0ce65 100644 (file)
@@ -38,7 +38,6 @@ export class TaskWrapperService {
         (resp) => {
           task.success = false;
           task.exception = resp.error;
-          this.notificationService.notifyTask(task);
           observer.error();
         },
         () => {