From 58430dee934cc10cf55c4a75692390f0c57bf836 Mon Sep 17 00:00:00 2001 From: Pedro Gonzalez Gomez Date: Mon, 18 Sep 2023 18:34:28 +0200 Subject: [PATCH] mgr/dashboard: fix prometheus queries subscriptions Fixes: https://tracker.ceph.com/issues/62868 Signed-off-by: Pedro Gonzalez Gomez (cherry picked from commit b7f25e63178080800f96f1cdcdd620fea200ea58) --- .../dashboard/dashboard-v3.component.ts | 14 ++------------ .../rgw-overview-dashboard.component.ts | 4 +--- .../src/app/shared/api/prometheus.service.ts | 6 ++++++ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.ts index 01bd621d35ae2..cf2cb0b197401 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.ts @@ -3,7 +3,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import _ from 'lodash'; import { Observable, Subscription } from 'rxjs'; import { take } from 'rxjs/operators'; -import moment from 'moment'; import { HealthService } from '~/app/shared/api/health.service'; import { OsdService } from '~/app/shared/api/osd.service'; @@ -68,13 +67,6 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit }; telemetryEnabled: boolean; telemetryURL = 'https://telemetry-public.ceph.com/'; - timerGetPrometheusDataSub: Subscription; - timerTime = 30000; - readonly lastHourDateObject = { - start: moment().unix() - 3600, - end: moment().unix(), - step: 14 - }; origin = window.location.origin; constructor( @@ -100,7 +92,7 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit this.getHealth(); this.getCapacityCardData(); }); - this.getPrometheusData(this.lastHourDateObject); + this.getPrometheusData(this.prometheusService.lastHourDateObject); this.getDetailsCardData(); this.getTelemetryReport(); } @@ -114,9 +106,7 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit } ngOnDestroy() { this.interval.unsubscribe(); - if (this.timerGetPrometheusDataSub) { - this.timerGetPrometheusDataSub.unsubscribe(); - } + this.prometheusService.unsubscribe(); } getHealth() { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-overview-dashboard/rgw-overview-dashboard.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-overview-dashboard/rgw-overview-dashboard.component.ts index c66159322eced..00537b32af008 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-overview-dashboard/rgw-overview-dashboard.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-overview-dashboard/rgw-overview-dashboard.component.ts @@ -144,9 +144,7 @@ export class RgwOverviewDashboardComponent implements OnInit, OnDestroy { this.ZoneSUb.unsubscribe(); this.BucketSub.unsubscribe(); this.HealthSub.unsubscribe(); - if (this.timerGetPrometheusDataSub) { - this.timerGetPrometheusDataSub.unsubscribe(); - } + this.prometheusService.unsubscribe(); } getPrometheusData(selectedTime: any) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts index 21420d7629fb5..6917b37662a6f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts @@ -32,6 +32,12 @@ export class PrometheusService { constructor(private http: HttpClient) {} + unsubscribe() { + if (this.timerGetPrometheusDataSub) { + this.timerGetPrometheusDataSub.unsubscribe(); + } + } + getPrometheusData(params: any): any { return this.http.get(`${this.baseURL}/data`, { params }); } -- 2.39.5