Skip to content

Commit 36a4a72

Browse files
committed
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 <[email protected]>
1 parent 5d6a81f commit 36a4a72

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/pybind/mgr/dashboard/services/nvmeof_conf.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# -*- coding: utf-8 -*-
22

33
import json
4+
import logging
45

56
from orchestrator import OrchestratorError
67

78
from .. import mgr
89
from ..exceptions import DashboardException
910
from ..services.orchestrator import OrchClient
1011

12+
logger = logging.getLogger('nvmeof_conf')
1113

1214
class NvmeofGatewayAlreadyExists(Exception):
1315
def __init__(self, gateway_name):
@@ -87,12 +89,9 @@ def get_client_key(cls, service_name: str):
8789

8890
@classmethod
8991
def get_root_ca_cert(cls, service_name: str):
90-
try:
91-
root_ca_cert = cls.from_cert_store('nvmeof_root_ca_cert', service_name)
92-
return root_ca_cert.encode()
93-
except DashboardException:
94-
# If root_ca_cert is not set, use server_cert as root_ca_cert
95-
return cls.get_server_cert(service_name)
92+
root_ca_cert = cls.from_cert_store('nvmeof_root_ca_cert', service_name)
93+
# If root_ca_cert is not set, use server_cert as root_ca_cert
94+
return root_ca_cert.encode() if root_ca_cert else cls.get_server_cert(service_name)
9695

9796
@classmethod
9897
def get_server_cert(cls, service_name: str):
@@ -108,7 +107,7 @@ def from_cert_store(cls, entity: str, service_name: str, key=False):
108107
return orch.cert_store.get_key(entity, service_name)
109108
return orch.cert_store.get_cert(entity, service_name)
110109
return None
111-
except OrchestratorError as e:
112-
raise DashboardException(
113-
msg=f'Failed to get {entity} for {service_name}: {e}',
114-
)
110+
except OrchestratorError:
111+
# just return None if any orchestrator error is raised
112+
# otherwise nvmeof api will raise this error and doesn't proceed.
113+
return None

0 commit comments

Comments
 (0)