From: John Mulligan Date: Wed, 18 Jun 2025 21:18:30 +0000 (-0400) Subject: mgr/cephadm: teach ctdb nodes logic about bind_addrs X-Git-Tag: testing/wip-jcollin-testing-20250821.034803-tentacle~26^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=217e46277fad4c70919579ff3273436e9c4a62e8;p=ceph-ci.git mgr/cephadm: teach ctdb nodes logic about bind_addrs Within the cephadm smb service class we have logic to help manage CTDB's nodes. Ensure that this node handling logic also conforms to the recent addition of the smb service's bind_addrs field. Signed-off-by: John Mulligan (cherry picked from commit 512e2585353f1b40a0af0a85ff5437cdb050d01f) --- diff --git a/src/pybind/mgr/cephadm/services/smb.py b/src/pybind/mgr/cephadm/services/smb.py index f2d97c2aa5e..edb49903891 100644 --- a/src/pybind/mgr/cephadm/services/smb.py +++ b/src/pybind/mgr/cephadm/services/smb.py @@ -311,11 +311,14 @@ class SMBService(CephService): from smb import clustermeta + addr_src = ( + AddressPool.from_spec(smb_spec) if smb_spec.bind_addrs else None + ) smb_dmap: clustermeta.DaemonMap = {} for dd in daemons: assert dd.daemon_type and dd.daemon_id assert dd.hostname - host_ip = dd.ip or self.mgr.inventory.get_addr(dd.hostname) + host_ip = self._ctdb_node_ip(dd, addr_src) smb_dmap[dd.name()] = { 'daemon_type': dd.daemon_type, 'daemon_id': dd.daemon_id, @@ -324,9 +327,7 @@ class SMBService(CephService): # specific ctdb_ip? (someday?) } if daemon_spec: - host_ip = daemon_spec.ip or self.mgr.inventory.get_addr( - daemon_spec.host - ) + host_ip = self._ctdb_node_ip(daemon_spec, addr_src) smb_dmap[daemon_spec.name()] = { 'daemon_type': daemon_spec.daemon_type, 'daemon_id': daemon_spec.daemon_id, @@ -338,6 +339,28 @@ class SMBService(CephService): with clustermeta.rados_object(self.mgr, uri) as cmeta: cmeta.sync_ranks(rank_map, smb_dmap) + def _ctdb_node_ip( + self, daemon: Any, addr_src: Optional['AddressPool'] = None + ) -> str: + if isinstance(daemon, CephadmDaemonDeploySpec): + ip = daemon.ip + hostname = daemon.host or '' + elif isinstance(daemon, DaemonDescription): + ip = daemon.ip + hostname = daemon.hostname or '' + else: + raise ValueError('unexpected deamon type: {daemon!r}') + logger.debug('_ctdb_node_ip: ip=%r, hostname=%r', ip, hostname) + if not ip: + assert hostname, 'no hostname available' + ip = self.mgr.inventory.get_addr(hostname) + assert ip, "failed to assign ip" + if addr_src and ip not in addr_src: + raise ValueError( + f'{ip} for host {hostname} does not match bind_addrs' + ) + return ip + Network = Union[ipaddress.IPv4Network, ipaddress.IPv6Network]