]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix readonly landingpage 57070/head
authorPedro Gonzalez Gomez <pegonzal@redhat.com>
Wed, 24 Apr 2024 08:48:11 +0000 (10:48 +0200)
committerPedro Gonzalez Gomez <pegonzal@redhat.com>
Thu, 23 May 2024 11:28:19 +0000 (13:28 +0200)
Fixes: https://tracker.ceph.com/issues/65643
Signed-off-by: Pedro Gonzalez Gomez <pegonzal@redhat.com>
src/pybind/mgr/dashboard/controllers/health.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.ts
src/pybind/mgr/dashboard/frontend/src/app/core/layouts/workbench-layout/workbench-layout.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/health.service.ts
src/pybind/mgr/dashboard/openapi.yaml

index 633d37a327eaf8d04ccd2fe2ea9bfe52be9e5b29..3edc386b01232bfdda8f135c19ba9b3b9eda9f22 100644 (file)
@@ -300,3 +300,7 @@ class Health(BaseController):
     @Endpoint()
     def get_cluster_fsid(self):
         return mgr.get('config')['fsid']
+
+    @Endpoint()
+    def get_telemetry_status(self):
+        return mgr.get_module_option_ex('telemetry', 'enabled', False)
index 9b3c050064f95b90786ca2001e993e54d847a7c6..c0ec766ab8b9847dee9be118a8e57b61d96fcb3e 100644 (file)
@@ -100,17 +100,20 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit
 
   ngOnInit() {
     super.ngOnInit();
-    this.isHardwareEnabled$ = this.getHardwareConfig();
-    this.hardwareSummary$ = this.hardwareSubject.pipe(
-      switchMap(() =>
-        this.hardwareService.getSummary().pipe(
-          switchMap((data: any) => {
-            this.hasHardwareError = data.host.flawed;
-            return of(data);
-          })
+    if (this.permissions.configOpt.read) {
+      this.isHardwareEnabled$ = this.getHardwareConfig();
+      this.hardwareSummary$ = this.hardwareSubject.pipe(
+        switchMap(() =>
+          this.hardwareService.getSummary().pipe(
+            switchMap((data: any) => {
+              this.hasHardwareError = data.host.flawed;
+              return of(data);
+            })
+          )
         )
-      )
-    );
+      );
+      this.managedByConfig$ = this.settingsService.getValues('MANAGED_BY_CLUSTERS');
+    }
     this.interval = this.refreshIntervalService.intervalData$.subscribe(() => {
       this.getHealth();
       this.getCapacityCardData();
@@ -119,7 +122,6 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit
     this.getPrometheusData(this.prometheusService.lastHourDateObject);
     this.getDetailsCardData();
     this.getTelemetryReport();
-    this.managedByConfig$ = this.settingsService.getValues('MANAGED_BY_CLUSTERS');
     this.prometheusAlertService.getAlerts(true);
   }
 
@@ -180,8 +182,8 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit
   }
 
   private getTelemetryReport() {
-    this.mgrModuleService.getConfig('telemetry').subscribe((resp: any) => {
-      this.telemetryEnabled = resp?.enabled;
+    this.healthService.getTelemetryStatus().subscribe((enabled: boolean) => {
+      this.telemetryEnabled = enabled;
     });
   }
 
index 8ddbddf2fe81493fe93625139df5ddeec7f1844b..054ebf8bba1120ea569ac361d1fef8db217507c0 100644 (file)
@@ -3,6 +3,8 @@ import { Router } from '@angular/router';
 
 import { Subscription } from 'rxjs';
 import { MultiClusterService } from '~/app/shared/api/multi-cluster.service';
+import { Permissions } from '~/app/shared/models/permissions';
+import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
 
 import { FaviconService } from '~/app/shared/services/favicon.service';
 import { SummaryService } from '~/app/shared/services/summary.service';
@@ -16,18 +18,24 @@ import { TaskManagerService } from '~/app/shared/services/task-manager.service';
 })
 export class WorkbenchLayoutComponent implements OnInit, OnDestroy {
   private subs = new Subscription();
+  permissions: Permissions;
 
   constructor(
     public router: Router,
     private summaryService: SummaryService,
     private taskManagerService: TaskManagerService,
     private multiClusterService: MultiClusterService,
-    private faviconService: FaviconService
-  ) {}
+    private faviconService: FaviconService,
+    private authStorageService: AuthStorageService
+  ) {
+    this.permissions = this.authStorageService.getPermissions();
+  }
 
   ngOnInit() {
-    this.subs.add(this.multiClusterService.startPolling());
-    this.subs.add(this.multiClusterService.startClusterTokenStatusPolling());
+    if (this.permissions.configOpt.read) {
+      this.subs.add(this.multiClusterService.startPolling());
+      this.subs.add(this.multiClusterService.startClusterTokenStatusPolling());
+    }
     this.subs.add(this.summaryService.startPolling());
     this.subs.add(this.taskManagerService.init(this.summaryService));
     this.faviconService.init();
index 42634a1481cf2fb596630e4508231df85ebe8915..b04a27b644d50c055ff62b4d02b177825f1caa24 100644 (file)
@@ -26,4 +26,8 @@ export class HealthService {
   getOrchestratorName() {
     return this.http.get('api/health/get_orchestrator_name');
   }
+
+  getTelemetryStatus() {
+    return this.http.get('api/health/get_telemetry_status');
+  }
 }
index 1c004bd8b3c7006a72a41bab03b4ef1c22de4002..4954e8552b49242d3bab1060a240b1cea399ef3c 100644 (file)
@@ -4916,6 +4916,28 @@ paths:
       - jwt: []
       tags:
       - Health
+  /api/health/get_telemetry_status:
+    get:
+      parameters: []
+      responses:
+        '200':
+          content:
+            application/vnd.ceph.api.v1.0+json:
+              type: object
+          description: OK
+        '400':
+          description: Operation exception. Please check the response body for details.
+        '401':
+          description: Unauthenticated access. Please login first.
+        '403':
+          description: Unauthorized access. Please check your permissions.
+        '500':
+          description: Unexpected error. Please check the response body for the stack
+            trace.
+      security:
+      - jwt: []
+      tags:
+      - Health
   /api/health/minimal:
     get:
       parameters: []