Skip to content

Commit 479dc16

Browse files
authored
Merge pull request ceph#62241 from rhcs-dashboard/fix-70413-main
mgr/dashboard: Show notification for multi-site sync status in case there is some error Reviewed-by: Nizamudeen A <[email protected]>
2 parents b58024e + 2519c94 commit 479dc16

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-overview-dashboard/rgw-overview-dashboard.component.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
1212
import { RgwRealmService } from '~/app/shared/api/rgw-realm.service';
1313
import { RgwZoneService } from '~/app/shared/api/rgw-zone.service';
1414
import { RgwZonegroupService } from '~/app/shared/api/rgw-zonegroup.service';
15+
import { ToastrModule } from 'ngx-toastr';
16+
import { SharedModule } from '~/app/shared/shared.module';
17+
import { ActivatedRoute } from '@angular/router';
1518

1619
describe('RgwOverviewDashboardComponent', () => {
1720
let component: RgwOverviewDashboardComponent;
@@ -22,6 +25,7 @@ describe('RgwOverviewDashboardComponent', () => {
2225
let listZonesSpy: jest.SpyInstance;
2326
let fetchAndTransformBucketsSpy: jest.SpyInstance;
2427
let totalBucketsAndUsersSpy: jest.SpyInstance;
28+
let params: Record<string, any>;
2529

2630
const totalNumObjectsSubject = new BehaviorSubject<number>(290);
2731
const totalUsedCapacitySubject = new BehaviorSubject<number>(9338880);
@@ -79,9 +83,13 @@ describe('RgwOverviewDashboardComponent', () => {
7983
averageObjectSize$: averageObjectSizeSubject.asObservable(),
8084
getTotalBucketsAndUsersLength: jest.fn()
8185
}
86+
},
87+
{
88+
provide: ActivatedRoute,
89+
useValue: { params: { subscribe: (fn: Function) => fn(params) } }
8290
}
8391
],
84-
imports: [HttpClientTestingModule]
92+
imports: [HttpClientTestingModule, ToastrModule.forRoot(), SharedModule]
8593
}).compileComponents();
8694
fixture = TestBed.createComponent(RgwOverviewDashboardComponent);
8795
component = fixture.componentInstance;

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-overview-dashboard/rgw-overview-dashboard.component.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { RgwPromqls as queries } from '~/app/shared/enum/dashboard-promqls.enum'
1717
import { Icons } from '~/app/shared/enum/icons.enum';
1818
import { RgwMultisiteService } from '~/app/shared/api/rgw-multisite.service';
1919
import { catchError, shareReplay, switchMap, tap } from 'rxjs/operators';
20+
import { NotificationService } from '~/app/shared/services/notification.service';
21+
import { NotificationType } from '~/app/shared/enum/notification-type.enum';
2022

2123
@Component({
2224
selector: 'cd-rgw-overview-dashboard',
@@ -60,7 +62,6 @@ export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
6062
loading = true;
6163
multisiteSyncStatus$: Observable<any>;
6264
subject = new ReplaySubject<any>();
63-
syncCardLoading = true;
6465
fetchDataSub: Subscription;
6566

6667
constructor(
@@ -72,7 +73,8 @@ export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
7273
private rgwZoneService: RgwZoneService,
7374
private rgwBucketService: RgwBucketService,
7475
private prometheusService: PrometheusService,
75-
private rgwMultisiteService: RgwMultisiteService
76+
private rgwMultisiteService: RgwMultisiteService,
77+
private notificationService: NotificationService
7678
) {
7779
this.permissions = this.authStorageService.getPermissions();
7880
}
@@ -93,8 +95,8 @@ export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
9395
this.averageObjectSize = averageSize;
9496
this.rgwBucketCount = bucketData.buckets_count;
9597
this.UserCount = bucketData.users_count;
96-
this.getSyncStatus();
9798
});
99+
this.getSyncStatus();
98100
});
99101
this.realmSub = this.rgwRealmService.list().subscribe((data: any) => {
100102
this.rgwRealmCount = data['realms'].length;
@@ -115,16 +117,20 @@ export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
115117
this.metadataSyncInfo = data['metadataSyncInfo'];
116118
if (this.replicaZonesInfo.length === 0) {
117119
this.showMultisiteCard = false;
118-
this.syncCardLoading = false;
119120
this.loading = false;
120121
}
121122
[this.realm, this.zonegroup, this.zone] = data['primaryZoneData'];
122123
}),
123124
catchError((err) => {
124-
this.showMultisiteCard = false;
125-
this.syncCardLoading = false;
126-
this.loading = false;
127125
err.preventDefault();
126+
this.loading = false;
127+
this.showMultisiteCard = false;
128+
const errorMessage = $localize`Unable to fetch sync status`;
129+
this.notificationService.show(
130+
NotificationType.error,
131+
errorMessage,
132+
err.error.detail || err.error.message
133+
);
128134
return of(true);
129135
})
130136
)

0 commit comments

Comments
 (0)