]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix group name bugs in the nvmeof API 60222/head
authorNizamudeen A <nia@redhat.com>
Wed, 9 Oct 2024 14:45:55 +0000 (20:15 +0530)
committerNizamudeen A <nia@redhat.com>
Fri, 11 Oct 2024 08:01:57 +0000 (13:31 +0530)
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 <nia@redhat.com>
src/pybind/mgr/cephadm/services/nvmeof.py
src/pybind/mgr/dashboard/services/nvmeof_conf.py

index 8b15aace373c56a84f12b2723caaeb534988bcd5..162815da24c73c090f39e77e2b3fa5a778d2aaea 100644 (file)
@@ -123,10 +123,9 @@ 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:
+                spec = cast(NvmeofServiceSpec,
+                            self.mgr.spec_store.all_specs.get(dd.service_name(), None))
                 service_name = dd.service_name()
                 if dd.hostname is None:
                     err_msg = ('Trying to config_dashboard nvmeof but no hostname is defined')
index 1802f8a5fce9fbbb2ba643c0791b5a713d8aeca1..2426c5990787435f0e78d091afcfba82c3286cb4 100644 (file)
@@ -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