]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Show notification for multisite sync status in case there is some... 62241/head
authorAashish Sharma <Aashish.Sharma1@ibm.com>
Wed, 12 Mar 2025 06:41:14 +0000 (12:11 +0530)
committerAashish Sharma <Aashish.Sharma1@ibm.com>
Tue, 27 May 2025 11:34:56 +0000 (17:04 +0530)
Fixes: https://tracker.ceph.com/issues/70413
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-overview-dashboard/rgw-overview-dashboard.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-overview-dashboard/rgw-overview-dashboard.component.ts

index c7aaddcd08fdb87eaeb592b06be3531c08b87c2e..079483ef2003c2525c1326d33d26658119a213e0 100644 (file)
@@ -12,6 +12,9 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
 import { RgwRealmService } from '~/app/shared/api/rgw-realm.service';
 import { RgwZoneService } from '~/app/shared/api/rgw-zone.service';
 import { RgwZonegroupService } from '~/app/shared/api/rgw-zonegroup.service';
+import { ToastrModule } from 'ngx-toastr';
+import { SharedModule } from '~/app/shared/shared.module';
+import { ActivatedRoute } from '@angular/router';
 
 describe('RgwOverviewDashboardComponent', () => {
   let component: RgwOverviewDashboardComponent;
@@ -22,6 +25,7 @@ describe('RgwOverviewDashboardComponent', () => {
   let listZonesSpy: jest.SpyInstance;
   let fetchAndTransformBucketsSpy: jest.SpyInstance;
   let totalBucketsAndUsersSpy: jest.SpyInstance;
+  let params: Record<string, any>;
 
   const totalNumObjectsSubject = new BehaviorSubject<number>(290);
   const totalUsedCapacitySubject = new BehaviorSubject<number>(9338880);
@@ -79,9 +83,13 @@ describe('RgwOverviewDashboardComponent', () => {
             averageObjectSize$: averageObjectSizeSubject.asObservable(),
             getTotalBucketsAndUsersLength: jest.fn()
           }
+        },
+        {
+          provide: ActivatedRoute,
+          useValue: { params: { subscribe: (fn: Function) => fn(params) } }
         }
       ],
-      imports: [HttpClientTestingModule]
+      imports: [HttpClientTestingModule, ToastrModule.forRoot(), SharedModule]
     }).compileComponents();
     fixture = TestBed.createComponent(RgwOverviewDashboardComponent);
     component = fixture.componentInstance;
index f3a99505e2cee920058115b7ca85a252159a7b19..062f66b113d7c906ac7072a311c392160a650900 100644 (file)
@@ -17,6 +17,8 @@ import { RgwPromqls as queries } from '~/app/shared/enum/dashboard-promqls.enum'
 import { Icons } from '~/app/shared/enum/icons.enum';
 import { RgwMultisiteService } from '~/app/shared/api/rgw-multisite.service';
 import { catchError, shareReplay, switchMap, tap } from 'rxjs/operators';
+import { NotificationService } from '~/app/shared/services/notification.service';
+import { NotificationType } from '~/app/shared/enum/notification-type.enum';
 
 @Component({
   selector: 'cd-rgw-overview-dashboard',
@@ -60,7 +62,6 @@ export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
   loading = true;
   multisiteSyncStatus$: Observable<any>;
   subject = new ReplaySubject<any>();
-  syncCardLoading = true;
   fetchDataSub: Subscription;
 
   constructor(
@@ -72,7 +73,8 @@ export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
     private rgwZoneService: RgwZoneService,
     private rgwBucketService: RgwBucketService,
     private prometheusService: PrometheusService,
-    private rgwMultisiteService: RgwMultisiteService
+    private rgwMultisiteService: RgwMultisiteService,
+    private notificationService: NotificationService
   ) {
     this.permissions = this.authStorageService.getPermissions();
   }
@@ -93,8 +95,8 @@ export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
         this.averageObjectSize = averageSize;
         this.rgwBucketCount = bucketData.buckets_count;
         this.UserCount = bucketData.users_count;
-        this.getSyncStatus();
       });
+      this.getSyncStatus();
     });
     this.realmSub = this.rgwRealmService.list().subscribe((data: any) => {
       this.rgwRealmCount = data['realms'].length;
@@ -115,16 +117,20 @@ export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
             this.metadataSyncInfo = data['metadataSyncInfo'];
             if (this.replicaZonesInfo.length === 0) {
               this.showMultisiteCard = false;
-              this.syncCardLoading = false;
               this.loading = false;
             }
             [this.realm, this.zonegroup, this.zone] = data['primaryZoneData'];
           }),
           catchError((err) => {
-            this.showMultisiteCard = false;
-            this.syncCardLoading = false;
-            this.loading = false;
             err.preventDefault();
+            this.loading = false;
+            this.showMultisiteCard = false;
+            const errorMessage = $localize`Unable to fetch sync status`;
+            this.notificationService.show(
+              NotificationType.error,
+              errorMessage,
+              err.error.detail || err.error.message
+            );
             return of(true);
           })
         )