From: John Mulligan Date: Wed, 11 Jun 2025 14:43:42 +0000 (-0400) Subject: pybind/cephadm: update service discovery to use custom smb port X-Git-Tag: v20.1.0~42^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c7c923a4a7f8cb72274033680294bc7d7c338f36;p=ceph.git pybind/cephadm: update service discovery to use custom smb port When smb is using custom ports the metrics port may not be the default. Teach the service_discovery.py module about smb custom ports and update a test to match. Signed-off-by: John Mulligan (cherry picked from commit 3b99fa284d322ab9a824a2d8d8ee649dd7ca2cb8) --- diff --git a/src/pybind/mgr/cephadm/service_discovery.py b/src/pybind/mgr/cephadm/service_discovery.py index 31e8423725a..ff877e59def 100644 --- a/src/pybind/mgr/cephadm/service_discovery.py +++ b/src/pybind/mgr/cephadm/service_discovery.py @@ -13,7 +13,6 @@ from mgr_module import ServiceInfoT from mgr_util import build_url from typing import Dict, List, TYPE_CHECKING, cast, Collection, Callable, NamedTuple, Optional, IO from cephadm.services.nfs import NFSService -from cephadm.services.smb import SMBService from cephadm.services.monitoring import AlertmanagerService, NodeExporterService, PrometheusService import secrets from mgr_util import verify_tls_files @@ -23,6 +22,8 @@ from cephadm.services.ingress import IngressSpec from cephadm.services.cephadmservice import CephExporterService from cephadm.services.nvmeof import NvmeofService +from ceph.deployment.service_spec import SMBSpec + if TYPE_CHECKING: from cephadm.module import CephadmOrchestrator @@ -276,8 +277,14 @@ class Root(Server): srv_entries = [] for dd in self.mgr.cache.get_daemons_by_type('smb'): assert dd.hostname is not None + try: + spec = cast(SMBSpec, self.mgr.spec_store[dd.service_name()].spec) + except KeyError: + # TODO: logging + continue + # TODO: needs updating once ip control/colocation is present addr = dd.ip if dd.ip else self.mgr.inventory.get_addr(dd.hostname) - port = SMBService.DEFAULT_EXPORTER_PORT + port = spec.metrics_exporter_port() srv_entries.append({ 'targets': [build_url(host=addr, port=port).lstrip('/')], 'labels': {'instance': dd.hostname} diff --git a/src/pybind/mgr/cephadm/tests/test_service_discovery.py b/src/pybind/mgr/cephadm/tests/test_service_discovery.py index 7723b2c1aae..48ce131b839 100644 --- a/src/pybind/mgr/cephadm/tests/test_service_discovery.py +++ b/src/pybind/mgr/cephadm/tests/test_service_discovery.py @@ -52,6 +52,10 @@ class FakeServiceSpec: def __init__(self, port): self.monitor_port = port + def metrics_exporter_port(self): + # TODO: for smb only + return 9922 + class FakeSpecDescription: def __init__(self, port):