From: Stephan Müller Date: Fri, 27 Jul 2018 14:15:07 +0000 (+0200) Subject: mgr/dashboard: Fix duplicate error messages X-Git-Tag: v14.0.1~742^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F23287%2Fhead;p=ceph.git mgr/dashboard: Fix duplicate error messages 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 --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts index 45910cd1905e..acd09955e784 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts @@ -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(); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.ts index bed55d3f608d..7409608fefd2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.ts @@ -38,7 +38,6 @@ export class TaskWrapperService { (resp) => { task.success = false; task.exception = resp.error; - this.notificationService.notifyTask(task); observer.error(); }, () => {