]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: RGW users and buckets tables are empty if the selected gateway is... 45868/head
authorVolker Theile <vtheile@suse.com>
Wed, 23 Mar 2022 12:24:04 +0000 (13:24 +0100)
committerVolker Theile <vtheile@suse.com>
Tue, 12 Apr 2022 08:10:33 +0000 (10:10 +0200)
Fixes: https://tracker.ceph.com/issues/54983
Signed-off-by: Volker Theile <vtheile@suse.com>
(cherry picked from commit 347d43d6e2bbf55fb0606af81ffb32d8d0447586)

src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-daemon.service.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-daemon.service.ts

index 93ef3378693672386fefbd25c5057661e704d10d..d669ddefcb3fbd11ce689e7d7c9ad1e2f8d3f076 100644 (file)
@@ -12,7 +12,7 @@ describe('RgwDaemonService', () => {
   let httpTesting: HttpTestingController;
   let selectDaemonSpy: jasmine.Spy;
 
-  const daemonList = RgwHelper.getDaemonList();
+  const daemonList: Array<RgwDaemon> = RgwHelper.getDaemonList();
   const retrieveDaemonList = (reqDaemonList: RgwDaemon[], daemon: RgwDaemon) => {
     service
       .request((params) => of(params))
@@ -76,4 +76,15 @@ describe('RgwDaemonService', () => {
     expect(selectDaemonSpy).toHaveBeenCalledTimes(1);
     expect(selectDaemonSpy).toHaveBeenCalledWith(noDefaultDaemonList[0]);
   }));
+
+  it('should update default daemon if not exist in daemon list', fakeAsync(() => {
+    const tmpDaemonList = [...daemonList];
+    service.selectDaemon(tmpDaemonList[1]); // Select 'default' daemon.
+    tmpDaemonList.splice(1, 1); // Remove 'default' daemon.
+    tmpDaemonList[0].default = true; // Set new 'default' daemon.
+    service.list().subscribe();
+    const testReq = httpTesting.expectOne('api/rgw/daemon');
+    testReq.flush(tmpDaemonList);
+    expect(service['selectedDaemon'].getValue()).toEqual(tmpDaemonList[0]);
+  }));
 });
index c947f3ed4559728f3b5d006cd80877057dc84294..5c513c7f1fa1c894790c8007bf35488d4d8a6fa8 100644 (file)
@@ -25,7 +25,10 @@ export class RgwDaemonService {
     return this.http.get<RgwDaemon[]>(this.url).pipe(
       tap((daemons: RgwDaemon[]) => {
         this.daemons.next(daemons);
-        if (_.isEmpty(this.selectedDaemon.getValue())) {
+        const selectedDaemon = this.selectedDaemon.getValue();
+        // Set or re-select the default daemon if the current one is not
+        // in the list anymore.
+        if (_.isEmpty(selectedDaemon) || undefined === _.find(daemons, { id: selectedDaemon.id })) {
           this.selectDefaultDaemon(daemons);
         }
       })