From: Aashish Sharma Date: Thu, 30 May 2024 20:02:35 +0000 (+0530) Subject: mgr/dashboard: fix context switcher and multi-cluster add cluster feature X-Git-Tag: v20.0.0~967^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=faa68920aabbf87996868d25d9434ddbbff67922;p=ceph.git mgr/dashboard: fix context switcher and multi-cluster add cluster feature 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 --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 03230f1a2df4..2314b853b7e7 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -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 diff --git a/src/pybind/mgr/cephadm/templates/services/prometheus/prometheus.yml.j2 b/src/pybind/mgr/cephadm/templates/services/prometheus/prometheus.yml.j2 index f45328efb6d6..83f603c2d6e8 100644 --- a/src/pybind/mgr/cephadm/templates/services/prometheus/prometheus.yml.j2 +++ b/src/pybind/mgr/cephadm/templates/services/prometheus/prometheus.yml.j2 @@ -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' diff --git a/src/pybind/mgr/dashboard/controllers/multi_cluster.py b/src/pybind/mgr/dashboard/controllers/multi_cluster.py index 4d97ddd29e14..753914949be7 100644 --- a/src/pybind/mgr/dashboard/controllers/multi_cluster.py +++ b/src/pybind/mgr/dashboard/controllers/multi_cluster.py @@ -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 diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster.component.ts index dc13d4c09ff1..229666c9a6b0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster.component.ts @@ -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);