Skip to content

Commit 49acf03

Browse files
committed
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 <[email protected]>
1 parent f2f7cc6 commit 49acf03

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/pybind/mgr/dashboard/frontend/src/app/shared/api/multi-cluster.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { HttpClient, HttpParams } from '@angular/common/http';
22
import { Injectable } from '@angular/core';
33
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
44
import { TimerService } from '../services/timer.service';
5-
import { filter } from 'rxjs/operators';
5+
import { filter, first } from 'rxjs/operators';
66
import { SummaryService } from '../services/summary.service';
77
import { Router } from '@angular/router';
88

@@ -48,7 +48,7 @@ export class MultiClusterService {
4848

4949
startClusterTokenStatusPolling() {
5050
let clustersTokenMap = new Map<string, { token: string; user: string }>();
51-
const dataSubscription = this.subscribe((resp: any) => {
51+
const dataSubscription = this.subscribeOnce((resp: any) => {
5252
const clustersConfig = resp['config'];
5353
let tempMap = new Map<string, { token: string; user: string }>();
5454
if (clustersConfig) {
@@ -92,13 +92,22 @@ export class MultiClusterService {
9292
}
9393

9494
refreshTokenStatus() {
95-
this.subscribe((resp: any) => {
95+
this.subscribeOnce((resp: any) => {
9696
const clustersConfig = resp['config'];
9797
let tempMap = this.getTempMap(clustersConfig);
9898
return this.checkTokenStatus(tempMap).subscribe(this.getClusterTokenStatusObserver());
9999
});
100100
}
101101

102+
subscribeOnce(next: (data: any) => void, error?: (error: any) => void) {
103+
return this.msData$
104+
.pipe(
105+
filter((value) => !!value),
106+
first()
107+
)
108+
.subscribe(next, error);
109+
}
110+
102111
subscribe(next: (data: any) => void, error?: (error: any) => void) {
103112
return this.msData$.pipe(filter((value) => !!value)).subscribe(next, error);
104113
}

0 commit comments

Comments
 (0)