]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix context switcher and multi-cluster add cluster feature
authorAashish Sharma <aasharma@li-e74156cc-2f67-11b2-a85c-e98659a63c5c.ibm.com>
Thu, 30 May 2024 20:02:35 +0000 (01:32 +0530)
committerAashish Sharma <aasharma@li-e74156cc-2f67-11b2-a85c-e98659a63c5c.ibm.com>
Wed, 11 Sep 2024 05:25:09 +0000 (10:55 +0530)
In multi-cluster dashboard, fix CORS error on switching the context switcher and allow to add more than one clusters in prometheus federation

Fixes: https://tracker.ceph.com/issues/66307
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/templates/services/prometheus/prometheus.yml.j2
src/pybind/mgr/dashboard/controllers/multi_cluster.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster.component.ts

index 03230f1a2df4f0c33382dbe79b7dc73d9abbcc1f..2314b853b7e7bb5d559345115cea0b33f024aa76 100644 (file)
@@ -3194,6 +3194,8 @@ Then run the following:
     @handle_orch_error
     def get_prometheus_cert(self) -> str:
         prometheus_cert = self.get_store(PrometheusService.PROMETHEUS_CERT_CFG_KEY)
+        if prometheus_cert is None:
+            prometheus_cert = ''
         return prometheus_cert
 
     @handle_orch_error
index f45328efb6d6de6f90594897800243adc3f2129c..83f603c2d6e8a913bb577ac951347d763e47af08 100644 (file)
@@ -196,7 +196,7 @@ scrape_configs:
 {% endif %}
 
 {% for url, details in clusters_credentials.items() %}
-  - job_name: 'federate'
+  - job_name: 'federate_{{ loop.index }}'
     scrape_interval: 15s
     honor_labels: true
     metrics_path: '/federate'
index 4d97ddd29e149d49b15f08f20f8ac5e585b4f0f1..753914949be7060d3fef1adad57d6f9dd5d41e81 100644 (file)
@@ -248,7 +248,7 @@ class MultiCluster(RESTController):
         multicluster_config.update({'current_url': config['url']})
         multicluster_config.update({'current_user': config['user']})
         Settings.MULTICLUSTER_CONFIG = json.dumps(multicluster_config)
-        return Settings.MULTICLUSTER_CONFIG
+        return multicluster_config
 
     @Endpoint('PUT')
     @UpdatePermission
@@ -268,11 +268,13 @@ class MultiCluster(RESTController):
                                                           'reconnect')
 
             prometheus_url = self._proxy('GET', url, 'api/multi-cluster/get_prometheus_api_url',
-                                         token=cluster_token)
+                                         token=cluster_token, verify=ssl_verify,
+                                         cert=ssl_certificate)
 
             prometheus_access_info = self._proxy('GET', url,
                                                  'ui-api/multi-cluster/get_prometheus_access_info',  # noqa E501 #pylint: disable=line-too-long
-                                                 token=cluster_token)
+                                                 token=cluster_token, verify=ssl_verify,
+                                                 cert=ssl_certificate)
 
         if username and cluster_token and prometheus_url and prometheus_access_info:
             if "config" in multicluster_config:
@@ -303,7 +305,7 @@ class MultiCluster(RESTController):
                         cluster['ssl_verify'] = verify
                         cluster['ssl_certificate'] = ssl_certificate if verify else ''
         Settings.MULTICLUSTER_CONFIG = json.dumps(multicluster_config)
-        return Settings.MULTICLUSTER_CONFIG
+        return multicluster_config
 
     @Endpoint(method='DELETE')
     @DeletePermission
@@ -343,7 +345,7 @@ class MultiCluster(RESTController):
                     break
 
         Settings.MULTICLUSTER_CONFIG = json.dumps(multicluster_config)
-        return Settings.MULTICLUSTER_CONFIG
+        return multicluster_config
 
     @Endpoint()
     @ReadPermission
index dc13d4c09ff1a3764bdefba46c459932b596a67c..229666c9a6b0a3c411207369eccba97dd57314ce 100644 (file)
@@ -326,7 +326,7 @@ export class MultiClusterComponent implements OnInit, OnDestroy {
     }
 
     const clusters: ClusterInfo[] = [];
-    this.queriesResults.TOTAL_CAPACITY?.forEach((totalCapacityMetric: any) => {
+    this.queriesResults.TOTAL_CAPACITY?.forEach((totalCapacityMetric: any, index:number) => {
       const clusterName = totalCapacityMetric.metric.cluster;
       const totalCapacity = parseInt(totalCapacityMetric.value[1]);
       const getMgrMetadata = this.findCluster(this.queriesResults?.MGR_METADATA, clusterName);
@@ -339,8 +339,9 @@ export class MultiClusterComponent implements OnInit, OnDestroy {
       const osds = this.findClusterData(this.queriesResults?.OSDS, clusterName);
       const status = this.findClusterData(this.queriesResults?.HEALTH_STATUS, clusterName);
       const available_capacity = totalCapacity - usedCapacity;
+      const federateJobName = `federate_${index + 1}`;
       const federateMetrics = this.queriesResults?.FEDERATE_UP_METRIC.filter(
-        (metric: any) => metric.metric.job === 'federate'
+        (metric: any) => metric.metric.job === federateJobName
       );
       this.checkFederateMetricsStatus(federateMetrics);