From 287ff3b3603291763b3cd08f9b1543fe60d5f3b9 Mon Sep 17 00:00:00 2001 From: Afreen Misbah Date: Wed, 25 Sep 2024 16:45:10 +0530 Subject: [PATCH] mgr/dashboard: Allow adding all listeners unders a subsystems 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 --- .../mgr/dashboard/controllers/nvmeof.py | 2 +- .../mgr/dashboard/services/nvmeof_client.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/nvmeof.py b/src/pybind/mgr/dashboard/controllers/nvmeof.py index ec9c9897081..757b9e8ac02 100644 --- a/src/pybind/mgr/dashboard/controllers/nvmeof.py +++ b/src/pybind/mgr/dashboard/controllers/nvmeof.py @@ -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, diff --git a/src/pybind/mgr/dashboard/services/nvmeof_client.py b/src/pybind/mgr/dashboard/services/nvmeof_client.py index d6b126500b0..e0ea6d1e48b 100644 --- a/src/pybind/mgr/dashboard/services/nvmeof_client.py +++ b/src/pybind/mgr/dashboard/services/nvmeof_client.py @@ -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) -- 2.39.5