]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard : Fix secure-monitoring-stack creds issue
authorAbhishek Desai <abhishek.desai1@ibm.com>
Wed, 8 Oct 2025 07:10:22 +0000 (12:40 +0530)
committerAbhishek Desai <abhishek.desai1@ibm.com>
Fri, 10 Oct 2025 08:31:18 +0000 (14:01 +0530)
Fixes : https://tracker.ceph.com/issues/73379

Signed-off-by: Abhishek Desai <abhishek.desai1@ibm.com>
src/pybind/mgr/dashboard/controllers/prometheus.py
src/pybind/mgr/dashboard/services/orchestrator.py

index 244106d470d53434064832862e4feeebaead974b..1c38e083fa3058f6a3f3a4f5f8258ae409d123f3 100644 (file)
@@ -107,7 +107,17 @@ class PrometheusRESTController(RESTController):
         return response
 
     def get_access_info(self, module_name):
-        # type (str, str, str, str, str)
+        """
+        Fetches credentials and certificate files for Prometheus/Alertmanager API access.
+        Cases handled:
+        - If secure_monitoring_stack and/or mgmt_gateway enabled:
+                fetch credentials (user, password, certs).
+        - If oauth2-proxy enabled: fetch credentials,
+                but only certs are used (user/password ignored).
+        - If not cephadm backend: returns credentials with all fields as None.
+        Returns:
+            Credentials namedtuple with user, password, ca_cert_file, cert_file, pkey_file.
+        """
 
         def write_to_tmp_file(content):
             # type (str)
@@ -138,11 +148,11 @@ class PrometheusRESTController(RESTController):
         cached_creds = self._get_cached_credentials(module_name)
         if cached_creds:
             return cached_creds
-
-        secure_monitoring_stack = mgr.get_module_option_ex('cephadm', 'secure_monitoring_stack')
-        if not secure_monitoring_stack:
-            return Credentials(user, password, ca_cert_file, cert_file, pkey_file)
         orch_client = OrchClient.instance()
+        security_config = orch_client.monitoring.get_security_config()
+        if not security_config.get('security_enabled', False):
+            return Credentials(user, password, ca_cert_file, cert_file, pkey_file)
+
         if orch_client.available():
             if module_name == 'prometheus':
                 access_info = orch_client.monitoring.get_prometheus_access_info()
index 22190f45fad7b7d498c37773679667976e7214d5..769172b9bfade23655cbaac63f1542af7b7f3eb3 100644 (file)
@@ -234,6 +234,11 @@ class MonitoringManager(ResourceManager):
         """Get Alertmanager access information"""
         return self.api.get_alertmanager_access_info()
 
+    @wait_api_result
+    def get_security_config(self) -> Dict[str, str]:
+        """Get security config information"""
+        return self.api.get_security_config()
+
 
 class OrchClient(object):