From e8edf47047d49cd9e6a336ee47e28b3b374bca83 Mon Sep 17 00:00:00 2001 From: Adam King Date: Wed, 12 Feb 2025 14:31:36 -0500 Subject: [PATCH] mgr/cephadm: block deploying nvmeof daemons of different groups on same host As recommended by the nvmeof team, we shouldn't have nvmeof teams of different groups on the same host Signed-off-by: Adam King --- src/pybind/mgr/cephadm/services/nvmeof.py | 26 ++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/cephadm/services/nvmeof.py b/src/pybind/mgr/cephadm/services/nvmeof.py index b522a762032..43b4c2b086f 100644 --- a/src/pybind/mgr/cephadm/services/nvmeof.py +++ b/src/pybind/mgr/cephadm/services/nvmeof.py @@ -7,7 +7,12 @@ from ipaddress import ip_address, IPv6Address from mgr_module import HandleCommandResult from ceph.deployment.service_spec import NvmeofServiceSpec -from orchestrator import OrchestratorError, DaemonDescription, DaemonDescriptionStatus +from orchestrator import ( + OrchestratorError, + DaemonDescription, + DaemonDescriptionStatus, + HostSpec, +) from .cephadmservice import CephadmDaemonDeploySpec, CephService from .service_registry import register_cephadm_service from .. import utils @@ -234,3 +239,22 @@ class NvmeofService(CephService): _, _, err = self.mgr.mon_command(cmd) if err: self.mgr.log.error(f"Unable to send monitor command {cmd}, error {err}") + + def get_blocking_daemon_hosts(self, service_name: str) -> List[HostSpec]: + # we should not deploy nvmeof daemons on hosts that have nvmeof daemons + # from services with a different "group" attribute (as recommended by + # the nvmeof team) + spec = cast(NvmeofServiceSpec, self.mgr.spec_store[service_name].spec) + nvmeof_group = cast(NvmeofServiceSpec, spec).group + blocking_daemons: List[DaemonDescription] = [] + other_group_nvmeof_services = [ + nspec for nspec in self.mgr.spec_store.get_specs_by_type('nvmeof').values() + if cast(NvmeofServiceSpec, nspec).group != nvmeof_group + ] + for other_group_nvmeof_service in other_group_nvmeof_services: + blocking_daemons += self.mgr.cache.get_daemons_by_service(other_group_nvmeof_service.service_name()) + blocking_daemon_hosts = [ + HostSpec(hostname=blocking_daemon.hostname) + for blocking_daemon in blocking_daemons if blocking_daemon.hostname is not None + ] + return blocking_daemon_hosts -- 2.39.5