]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add whitelist to guard 27492/head
authorErnesto Puerta <epuertat@redhat.com>
Fri, 5 Apr 2019 16:22:30 +0000 (18:22 +0200)
committerErnesto Puerta <epuertat@redhat.com>
Wed, 10 Apr 2019 12:09:28 +0000 (14:09 +0200)
After PR https://github.com/ceph/ceph/pull/26572, when RGW is not
  configured, accessing /rgw drop-down (daemons, users or buckets)
  results in nothing apparently happening (not even an error).

  Under the curtains, what is happening is that the ModuleStatusGuard
  has redirected the route to the rgw/501, but as this route is now
  under parent rgw route handler, which sets CanActivateChild guards,
  this results in a new ModuleStatusGuard invokation, a subsequent
  failure and a new redirection to rgw/501.

  Several approaches could be taken here:
  - Remove error pages from lazy-loaded modules. Probably it does not
  make sense to have a 501 page per component.
  - Add some whitelist to avoid this kind of loop (e.g.: 501, or any
      error page).
  - Set a max number of redirections (cautionary measure).

Fixes: https://tracker.ceph.com/issues/39125
Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
(cherry picked from commit c64b815386d9b7b89c69fb7e8387c7b7b7cf408c)
Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts

index 2528826783c25911de432e79457febd8474d497d..9912d67bea5e4cf76869afbcc030bab3ca103ab8 100644 (file)
@@ -53,6 +53,7 @@ describe('ModuleStatusGuardService', () => {
     httpClient = TestBed.get(HttpClient);
     router = TestBed.get(Router);
     route = new ActivatedRouteSnapshot();
+    route.url = [];
     route.data = {
       moduleStatusGuardConfig: {
         apiPath: 'bar',
index f37024ea63c3429546d35d53d24f39700a3a740c..98c4b490a7039a42d3c66f6b0f0d0e005a1b3e87 100644 (file)
@@ -36,6 +36,9 @@ import { ServicesModule } from './services.module';
   providedIn: ServicesModule
 })
 export class ModuleStatusGuardService implements CanActivate, CanActivateChild {
+  // TODO: Hotfix - remove WHITELIST'ing when a generic ErrorComponent is implemented
+  static readonly WHITELIST: string[] = ['501'];
+
   constructor(private http: HttpClient, private router: Router) {}
 
   canActivate(route: ActivatedRouteSnapshot) {
@@ -47,6 +50,9 @@ export class ModuleStatusGuardService implements CanActivate, CanActivateChild {
   }
 
   private doCheck(route: ActivatedRouteSnapshot) {
+    if (route.url.length > 0 && ModuleStatusGuardService.WHITELIST.includes(route.url[0].path)) {
+      return observableOf(true);
+    }
     const config = route.data['moduleStatusGuardConfig'];
     return this.http.get(`/api/${config.apiPath}/status`).pipe(
       map((resp: any) => {