]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/cephadm: update service discovery to use custom smb port
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 11 Jun 2025 14:43:42 +0000 (10:43 -0400)
committerAdam King <adking@redhat.com>
Wed, 9 Jul 2025 15:52:24 +0000 (11:52 -0400)
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 <jmulligan@redhat.com>
(cherry picked from commit 3b99fa284d322ab9a824a2d8d8ee649dd7ca2cb8)

src/pybind/mgr/cephadm/service_discovery.py
src/pybind/mgr/cephadm/tests/test_service_discovery.py

index 31e8423725a3d4082f064e56d29f96b9b8b822f0..ff877e59defeb60b6e6c243d7d2d3955d4890482 100644 (file)
@@ -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}
index 7723b2c1aae628728a2acaa4166923c37246a559..48ce131b839a5cd8aa7756f1c20769e2e7590ed9 100644 (file)
@@ -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):