Skip to content

Commit 2f47f9d

Browse files
author
Alexander Indenbaum
committed
cephadm/nvmeof: support per-node gateway addresses
Added gateway and discovery address maps to the service specification. These maps store per-node service addresses. The address is first searched in the map, then in the spec address configuration. If neither is defined, the host IP is used as a fallback. Signed-off-by: Alexander Indenbaum <[email protected]>
1 parent 23e1842 commit 2f47f9d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/pybind/mgr/cephadm/services/nvmeof.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def prepare_create(self, daemon_spec: CephadmDaemonDeploySpec) -> CephadmDaemonD
3838
spec = cast(NvmeofServiceSpec, self.mgr.spec_store[daemon_spec.service_name].spec)
3939
nvmeof_gw_id = daemon_spec.daemon_id
4040
host_ip = self.mgr.inventory.get_addr(daemon_spec.host)
41+
map_addr = spec.addr_map.get(daemon_spec.host) if spec.addr_map else None
42+
map_discovery_addr = spec.discovery_addr_map.get(daemon_spec.host) if spec.discovery_addr_map else None
4143

4244
keyring = self.get_keyring_with_caps(self.get_auth_entity(nvmeof_gw_id),
4345
['mon', 'profile rbd',
@@ -47,8 +49,14 @@ def prepare_create(self, daemon_spec: CephadmDaemonDeploySpec) -> CephadmDaemonD
4749
transport_tcp_options = json.dumps(spec.transport_tcp_options) if spec.transport_tcp_options else None
4850
name = '{}.{}'.format(utils.name_to_config_section('nvmeof'), nvmeof_gw_id)
4951
rados_id = name[len('client.'):] if name.startswith('client.') else name
50-
addr = spec.addr or host_ip
51-
discovery_addr = spec.discovery_addr or host_ip
52+
53+
# The address is first searched in the per node address map,
54+
# then in the spec address configuration.
55+
# If neither is defined, the host IP is used as a fallback.
56+
addr = map_addr or spec.addr or host_ip
57+
self.mgr.log.info(f"gateway address: {addr} from {map_addr=} {spec.addr=} {host_ip=}")
58+
discovery_addr = map_discovery_addr or spec.discovery_addr or host_ip
59+
self.mgr.log.info(f"discovery address: {discovery_addr} from {map_discovery_addr=} {spec.discovery_addr=} {host_ip=}")
5260
context = {
5361
'spec': spec,
5462
'name': name,

src/python-common/ceph/deployment/service_spec.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,7 @@ def __init__(self,
13301330
name: Optional[str] = None,
13311331
group: Optional[str] = None,
13321332
addr: Optional[str] = None,
1333+
addr_map: Optional[Dict[str, str]] = None,
13331334
port: Optional[int] = None,
13341335
pool: Optional[str] = None,
13351336
enable_auth: bool = False,
@@ -1380,6 +1381,7 @@ def __init__(self,
13801381
{"in_capsule_data_size": 8192, "max_io_qpairs_per_ctrlr": 7},
13811382
tgt_cmd_extra_args: Optional[str] = None,
13821383
discovery_addr: Optional[str] = None,
1384+
discovery_addr_map: Optional[Dict[str, str]] = None,
13831385
discovery_port: Optional[int] = None,
13841386
log_level: Optional[str] = 'INFO',
13851387
log_files_enabled: Optional[bool] = True,
@@ -1414,6 +1416,8 @@ def __init__(self,
14141416
self.pool = pool
14151417
#: ``addr`` address of the nvmeof gateway
14161418
self.addr = addr
1419+
#: ``addr_map`` per node address map of the nvmeof gateways
1420+
self.addr_map = addr_map
14171421
#: ``port`` port of the nvmeof gateway
14181422
self.port = port or 5500
14191423
#: ``name`` name of the nvmeof gateway
@@ -1512,6 +1516,8 @@ def __init__(self,
15121516
self.tgt_cmd_extra_args = tgt_cmd_extra_args
15131517
#: ``discovery_addr`` address of the discovery service
15141518
self.discovery_addr = discovery_addr
1519+
#: ``discovery_addr_map`` per node address map of the discovery service
1520+
self.discovery_addr_map = discovery_addr_map
15151521
#: ``discovery_port`` port of the discovery service
15161522
self.discovery_port = discovery_port or 8009
15171523
#: ``log_level`` the nvmeof gateway log level

0 commit comments

Comments
 (0)