From ce9dd01eab037d0f2ac4c28bfafaff5f94bdeaa2 Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Tue, 16 Jul 2024 20:03:24 +0530 Subject: [PATCH] mgr/dashboard: nvmf apis broken for insecure channel because when no certificate, it raises an exception which stops the api call abruptly. Signed-off-by: Nizamudeen A (cherry picked from commit 36a4a72959c1428d7295f3e24e5f94c937cff6a6) --- .../mgr/dashboard/services/nvmeof_conf.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/pybind/mgr/dashboard/services/nvmeof_conf.py b/src/pybind/mgr/dashboard/services/nvmeof_conf.py index 3879e308db471..4d3f312eb485b 100644 --- a/src/pybind/mgr/dashboard/services/nvmeof_conf.py +++ b/src/pybind/mgr/dashboard/services/nvmeof_conf.py @@ -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 -- 2.39.5