From 872d25182d06d046fdf929a0c3640e613dd70146 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 13 Aug 2025 12:59:24 -0400 Subject: [PATCH] cephadm/smb: fix issue setting port of remote-control sidecar Use the new set of constants to ensure all components that touch the smb services use the same set of ports and port names. Ensure that the remote-control sidecar service's port can be customized. Signed-off-by: John Mulligan (cherry picked from commit 98d48538c16f57ceeb31e49b501303ef4c0bddc9) --- src/cephadm/cephadmlib/daemons/smb.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/cephadm/cephadmlib/daemons/smb.py b/src/cephadm/cephadmlib/daemons/smb.py index f7a70a8654225..688e4ff79112b 100644 --- a/src/cephadm/cephadmlib/daemons/smb.py +++ b/src/cephadm/cephadmlib/daemons/smb.py @@ -17,6 +17,8 @@ from typing import ( Tuple, ) +import ceph.smb.constants + from .. import context_getters from .. import daemon_form from .. import data_utils @@ -104,20 +106,35 @@ class BindInterface(NamedTuple): class Ports(enum.Enum): - SMB = 445 - SMBMETRICS = 9922 - CTDB = 4379 - REMOTE_CONTROL = 54445 + SMB = ceph.smb.constants.SMB_PORT + SMBMETRICS = ceph.smb.constants.SMBMETRICS_PORT + CTDB = ceph.smb.constants.CTDB_PORT + REMOTE_CONTROL = ceph.smb.constants.REMOTE_CONTROL_PORT def customized(self, service_ports: Dict[str, int]) -> int: """Return a custom port value if it is present in service_ports or the default port value if it is not present. """ - port = service_ports.get(self.name.lower()) + port = service_ports.get(str(self)) if port: return int(port) return int(self.value) + def __str__(self) -> str: + # NOTE: mypy is getting the key type below wrong. using reveal_type: + # >>> reveal_type(self.SMB) + # > note: Revealed type is "builtins.int" + # >>> reveal_type(self) + # > note: Revealed type is "cephadmlib.daemons.smb.Ports" + # maybe newer versions would not hit this issue? + names: Dict[Any, str] = { + self.SMB: ceph.smb.constants.SMB, + self.SMBMETRICS: ceph.smb.constants.SMBMETRICS, + self.CTDB: ceph.smb.constants.CTDB, + self.REMOTE_CONTROL: ceph.smb.constants.REMOTE_CONTROL, + } + return names[self] + @dataclasses.dataclass(frozen=True) class TLSFiles: -- 2.39.5