]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: nvmf apis broken for insecure channel
authorNizamudeen A <nia@redhat.com>
Tue, 16 Jul 2024 14:33:24 +0000 (20:03 +0530)
committerNizamudeen A <nia@redhat.com>
Tue, 16 Jul 2024 14:33:24 +0000 (20:03 +0530)
because when no certificate, it raises an exception which stops the api call
abruptly.

Signed-off-by: Nizamudeen A <nia@redhat.com>
src/pybind/mgr/dashboard/services/nvmeof_conf.py

index 3879e308db4714bbd69f75dd79bb5ded32e7dc9d..4d3f312eb485b883755bc42653523e3bf288fcd8 100644 (file)
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 
 import json
+import logging
 
 from orchestrator import OrchestratorError
 
@@ -8,6 +9,7 @@ from .. import mgr
 from ..exceptions import DashboardException
 from ..services.orchestrator import OrchClient
 
+logger = logging.getLogger('nvmeof_conf')
 
 class NvmeofGatewayAlreadyExists(Exception):
     def __init__(self, gateway_name):
@@ -87,12 +89,9 @@ class NvmeofGatewaysConfig(object):
 
     @classmethod
     def get_root_ca_cert(cls, service_name: str):
-        try:
-            root_ca_cert = cls.from_cert_store('nvmeof_root_ca_cert', service_name)
-            return root_ca_cert.encode()
-        except DashboardException:
-            # If root_ca_cert is not set, use server_cert as root_ca_cert
-            return cls.get_server_cert(service_name)
+        root_ca_cert = cls.from_cert_store('nvmeof_root_ca_cert', service_name)
+        # If root_ca_cert is not set, use server_cert as root_ca_cert
+        return root_ca_cert.encode() if root_ca_cert else cls.get_server_cert(service_name)
 
     @classmethod
     def get_server_cert(cls, service_name: str):
@@ -108,7 +107,7 @@ class NvmeofGatewaysConfig(object):
                     return orch.cert_store.get_key(entity, service_name)
                 return orch.cert_store.get_cert(entity, service_name)
             return None
-        except OrchestratorError as e:
-            raise DashboardException(
-                msg=f'Failed to get {entity} for {service_name}: {e}',
-            )
+        except OrchestratorError:
+            # just return None if any orchestrator error is raised
+            # otherwise nvmeof api will raise this error and doesn't proceed.
+            return None