From: Nizamudeen A Date: Wed, 9 Oct 2024 14:45:55 +0000 (+0530) Subject: mgr/dashboard: fix group name bugs in the nvmeof API X-Git-Tag: v19.2.1~151^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4b304f719469c34a0704d41a6621ddd2e1031c90;p=ceph.git mgr/dashboard: fix group name bugs in the nvmeof API there are 2 issues 1. in cephadm, i was always using the first daemon to populate the group in all the services for the dashboard config. 2. in the API, if there are more than 1 gateways listed in the config, rather than chosing a random gateway from the group, raise an exception and warn user to specify the gw_group parameter in the api request Fixes: https://tracker.ceph.com/issues/68463 Signed-off-by: Nizamudeen A (cherry picked from commit f9b50b2e88ae5d9ac4f2cab986527a0a12317da9) Conflicts: src/pybind/mgr/cephadm/services/nvmeof.py --- diff --git a/src/pybind/mgr/cephadm/services/nvmeof.py b/src/pybind/mgr/cephadm/services/nvmeof.py index e2d637844e8c0..969c2d14a41df 100644 --- a/src/pybind/mgr/cephadm/services/nvmeof.py +++ b/src/pybind/mgr/cephadm/services/nvmeof.py @@ -84,11 +84,10 @@ class NvmeofService(CephService): gateways = json.loads(out)['gateways'] cmd_dicts = [] - spec = cast(NvmeofServiceSpec, - self.mgr.spec_store.all_specs.get(daemon_descrs[0].service_name(), None)) - for dd in daemon_descrs: assert dd.hostname is not None + spec = cast(NvmeofServiceSpec, + self.mgr.spec_store.all_specs.get(dd.service_name(), None)) service_name = dd.service_name() if not spec: diff --git a/src/pybind/mgr/dashboard/services/nvmeof_conf.py b/src/pybind/mgr/dashboard/services/nvmeof_conf.py index 1802f8a5fce9f..2426c59907874 100644 --- a/src/pybind/mgr/dashboard/services/nvmeof_conf.py +++ b/src/pybind/mgr/dashboard/services/nvmeof_conf.py @@ -177,6 +177,18 @@ def _get_running_daemon_svc_config(svc_config, running_daemons): def _get_default_service(gateways): if gateways: - service_name = list(gateways.keys())[0] + gateway_keys = list(gateways.keys()) + # if there are more than 1 gateway, rather than chosing a random gateway + # from any of the group, raise an exception to make it clear that we need + # to specify the group name in the API request. + if len(gateway_keys) > 1: + raise DashboardException( + msg=( + "Multiple NVMe-oF gateway groups are configured. " + "Please specify the 'gw_group' parameter in the request." + ), + component="nvmeof" + ) + service_name = gateway_keys[0] return service_name, gateways[service_name][0]['service_url'] return None