From: John Mulligan Date: Mon, 16 Jun 2025 20:05:14 +0000 (-0400) Subject: mgr/cephadm: teach serve.py about host selector support X-Git-Tag: testing/wip-vshankar-testing-20250730.064735-debug~23^2~7 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e43800e968ff7d7c7736cfdd2d9b56d05bc3b437;p=ceph-ci.git mgr/cephadm: teach serve.py about host selector support A previous commit added a HostSelector protocol type to the schedule code. This change makes it so the function calling upon the HostAssignment class detects if a CephService provides a filter_host_candidates method - meaning the service class can act as a HostSelector. If the class can be a HostSelector pass it to the HostAssignment so that the custom selection operation can be run. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py index fa455c3cb68..4050bfe4c7c 100644 --- a/src/pybind/mgr/cephadm/serve.py +++ b/src/pybind/mgr/cephadm/serve.py @@ -26,7 +26,7 @@ import orchestrator from orchestrator import OrchestratorError, set_exception_subject, OrchestratorEvent, \ DaemonDescriptionStatus, daemon_type_to_service from cephadm.services.cephadmservice import CephadmDaemonDeploySpec -from cephadm.schedule import HostAssignment +from cephadm.schedule import HostAssignment, HostSelector from cephadm.autotune import MemoryAutotuner from cephadm.utils import forall_hosts, cephadmNoImage, is_repo_digest, \ CephadmNoImage, CEPH_TYPES, ContainerInspectInfo, SpecialHostLabels @@ -811,6 +811,7 @@ class CephadmServe: rank_map = None if svc.ranked(spec): rank_map = self.mgr.spec_store[spec.service_name()].rank_map or {} + host_selector = _host_selector(svc) ha = HostAssignment( spec=spec, hosts=self.mgr.cache.get_non_draining_hosts() if spec.service_name( @@ -826,7 +827,8 @@ class CephadmServe: primary_daemon_type=svc.primary_daemon_type(spec), per_host_daemon_type=svc.per_host_daemon_type(spec), rank_map=rank_map, - upgrade_in_progress=(self.mgr.upgrade.upgrade_state is not None) + upgrade_in_progress=(self.mgr.upgrade.upgrade_state is not None), + host_selector=host_selector, ) try: @@ -1831,3 +1833,9 @@ class CephadmServe: self.log.info(f"Deploying cephadm binary to {host}") await self.mgr.ssh._write_remote_file(host, self.mgr.cephadm_binary_path, self.mgr._cephadm, addr=addr) + + +def _host_selector(svc: Any) -> Optional[HostSelector]: + if hasattr(svc, 'filter_host_candidates'): + return cast(HostSelector, svc) + return None