From 49acf0317a5bdc428bcec2fd2cd0c05fa656ebf7 Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Wed, 12 Jun 2024 12:28:05 +0530 Subject: [PATCH] mgr/dashboard: fix token status being polled continously subscribe only once rather than continously subscribing Fixes: https://tracker.ceph.com/issues/66665 Signed-off-by: Nizamudeen A --- .../src/app/shared/api/multi-cluster.service.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/multi-cluster.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/multi-cluster.service.ts index 5a03abd22ff74..55d7d2b6c39c7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/multi-cluster.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/multi-cluster.service.ts @@ -2,7 +2,7 @@ import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable, Subscription } from 'rxjs'; import { TimerService } from '../services/timer.service'; -import { filter } from 'rxjs/operators'; +import { filter, first } from 'rxjs/operators'; import { SummaryService } from '../services/summary.service'; import { Router } from '@angular/router'; @@ -48,7 +48,7 @@ export class MultiClusterService { startClusterTokenStatusPolling() { let clustersTokenMap = new Map(); - const dataSubscription = this.subscribe((resp: any) => { + const dataSubscription = this.subscribeOnce((resp: any) => { const clustersConfig = resp['config']; let tempMap = new Map(); if (clustersConfig) { @@ -92,13 +92,22 @@ export class MultiClusterService { } refreshTokenStatus() { - this.subscribe((resp: any) => { + this.subscribeOnce((resp: any) => { const clustersConfig = resp['config']; let tempMap = this.getTempMap(clustersConfig); return this.checkTokenStatus(tempMap).subscribe(this.getClusterTokenStatusObserver()); }); } + subscribeOnce(next: (data: any) => void, error?: (error: any) => void) { + return this.msData$ + .pipe( + filter((value) => !!value), + first() + ) + .subscribe(next, error); + } + subscribe(next: (data: any) => void, error?: (error: any) => void) { return this.msData$.pipe(filter((value) => !!value)).subscribe(next, error); } -- 2.39.5