]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Allow adding all listeners unders a subsystems 59978/head
authorAfreen Misbah <afreen23.git@gmail.com>
Wed, 25 Sep 2024 11:15:10 +0000 (16:45 +0530)
committerAfreen Misbah <afreen23.git@gmail.com>
Tue, 1 Oct 2024 08:32:58 +0000 (14:02 +0530)
Issue:

- Currently a user cannot add all listeners under a subsystem
- This results into an error: `Failure adding nqn.2001-07.com.ceph:1725013182540 listener at 10.70.44.140:4420: Gateway's host name must match current host (dhcp47-54)`

Reason:

- The gateway address used while creating listener is random now in nvmeof client
- After checking the gateway logs of each node, its is found that no grpc request recieved for adding listener on the respective node rather going to the node that is chosen by default in nvmeof client.
- But nvmeof backend check that current gateway matches the one with sent in request for adding listener (ref: https://github.com/ceph/ceph-nvmeof/blob/devel/control/grpc.py#L2104)

Fix:

- Using `traddr` from listener API to set the current gateway address
- Since `traddr` gives only IP address, without port therefore extracting full address from `NvmeofGatewaysConfig.get_gateways_config()`
- This ensures correct path usage

Fixes https://tracker.ceph.com/issues/68229
Signed-off-by: Afreen Misbah <afreen23.git@gmail.com>
src/pybind/mgr/dashboard/controllers/nvmeof.py
src/pybind/mgr/dashboard/services/nvmeof_client.py

index ec9c9897081737b8b0874291af1f7c6de34604c9..757b9e8ac02cf44a4e60025d0ce9d7eff99995d2 100644 (file)
@@ -140,7 +140,7 @@ else:
             trsvcid: int = 4420,
             adrfam: int = 0,  # IPv4
         ):
-            return NVMeoFClient().stub.create_listener(
+            return NVMeoFClient(traddr=traddr).stub.create_listener(
                 NVMeoFClient.pb2.create_listener_req(
                     nqn=nqn,
                     host_name=host_name,
index d6b126500b0ddbf7c428a7146147d3fafc31e830..e0ea6d1e48b35191e999e16f51fcc51d331ce018 100644 (file)
@@ -22,7 +22,7 @@ else:
     class NVMeoFClient(object):
         pb2 = pb2
 
-        def __init__(self, gw_group: Optional[str] = None):
+        def __init__(self, gw_group: Optional[str] = None, traddr: Optional[str] = None):
             logger.info("Initiating nvmeof gateway connection...")
             try:
                 if not gw_group:
@@ -36,6 +36,23 @@ else:
                     f'Unable to retrieve the gateway info: {e}'
                 )
 
+            # While creating listener need to direct request to the gateway
+            # address where listener is supposed to be added.
+            if traddr:
+                gateways_info = NvmeofGatewaysConfig.get_gateways_config()
+                matched_gateway = next(
+                    (
+                        gateway
+                        for gateways in gateways_info['gateways'].values()
+                        for gateway in gateways
+                        if traddr in gateway['service_url']
+                    ),
+                    None
+                )
+                if matched_gateway:
+                    self.gateway_addr = matched_gateway.get('service_url')
+                    logger.debug("Gateway address set to: %s", self.gateway_addr)
+
             root_ca_cert = NvmeofGatewaysConfig.get_root_ca_cert(service_name)
             if root_ca_cert:
                 client_key = NvmeofGatewaysConfig.get_client_key(service_name)