]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix prometheus queries subscriptions 53669/head
authorPedro Gonzalez Gomez <pegonzal@redhat.com>
Mon, 18 Sep 2023 16:34:28 +0000 (18:34 +0200)
committerPedro Gonzalez Gomez <pegonzal@redhat.com>
Tue, 26 Sep 2023 08:36:42 +0000 (10:36 +0200)
Fixes: https://tracker.ceph.com/issues/62868
Signed-off-by: Pedro Gonzalez Gomez <pegonzal@redhat.com>
(cherry picked from commit b7f25e63178080800f96f1cdcdd620fea200ea58)

src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-overview-dashboard/rgw-overview-dashboard.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/prometheus.service.ts

index 01bd621d35ae289c75856bbc416aa06d4b4805f9..cf2cb0b19740164c6862f4d20bceb32cbcf0bef3 100644 (file)
@@ -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() {
index c66159322eceda793b55281ab0d9f3849f2cc18f..00537b32af008660c3796098f2bf0f660ba16bb4 100644 (file)
@@ -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) {
index 21420d7629fb5c6e8395d4018299c658086a780e..6917b37662a6f7cc3913c9bfb7b865a1059201cc 100644 (file)
@@ -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<any>(`${this.baseURL}/data`, { params });
   }