From: John Mulligan Date: Mon, 8 Jul 2024 19:14:30 +0000 (-0400) Subject: mgr/cephadm: allow services to be conditionally ranked X-Git-Tag: testing/wip-vshankar-testing-20240718.183435-debug~32^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6aba0cd30b936b7f93b3ba17dcca797991cef2b5;p=ceph-ci.git mgr/cephadm: allow services to be conditionally ranked Add a spec argument to the `ranked` function. If this function returns true the service will use ranks. In some cases we want 'rankedness' to be conditional on parameters of the given service spec. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index bd7981edc56..9cd3dae807f 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -3296,6 +3296,9 @@ Then run the following: 'data': self._preview_osdspecs(osdspecs=[cast(DriveGroupSpec, spec)])} svc = self.cephadm_services[spec.service_type] + rank_map = None + if svc.ranked(spec): + rank_map = self.spec_store[spec.service_name()].rank_map ha = HostAssignment( spec=spec, hosts=self.cache.get_schedulable_hosts(), @@ -3304,7 +3307,7 @@ Then run the following: networks=self.cache.networks, daemons=self.cache.get_daemons_by_service(spec.service_name()), allow_colo=svc.allow_colo(), - rank_map=self.spec_store[spec.service_name()].rank_map if svc.ranked() else None + rank_map=rank_map ) ha.validate() hosts, to_add, to_remove = ha.place() diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py index 59e06bbd024..eaaf4386f62 100644 --- a/src/pybind/mgr/cephadm/serve.py +++ b/src/pybind/mgr/cephadm/serve.py @@ -780,7 +780,7 @@ class CephadmServe: } rank_map = None - if svc.ranked(): + if svc.ranked(spec): rank_map = self.mgr.spec_store[spec.service_name()].rank_map or {} ha = HostAssignment( spec=spec, diff --git a/src/pybind/mgr/cephadm/services/cephadmservice.py b/src/pybind/mgr/cephadm/services/cephadmservice.py index ec9df98413a..72e6177bc1d 100644 --- a/src/pybind/mgr/cephadm/services/cephadmservice.py +++ b/src/pybind/mgr/cephadm/services/cephadmservice.py @@ -288,7 +288,7 @@ class CephadmService(metaclass=ABCMeta): """ return None - def ranked(self) -> bool: + def ranked(self, spec: ServiceSpec) -> bool: """ If True, we will assign a stable rank (0, 1, ...) and monotonically increasing generation (0, 1, ...) to each daemon we create/deploy. diff --git a/src/pybind/mgr/cephadm/services/nfs.py b/src/pybind/mgr/cephadm/services/nfs.py index f46f65b084b..a0d7da9bb7e 100644 --- a/src/pybind/mgr/cephadm/services/nfs.py +++ b/src/pybind/mgr/cephadm/services/nfs.py @@ -23,7 +23,7 @@ logger = logging.getLogger(__name__) class NFSService(CephService): TYPE = 'nfs' - def ranked(self) -> bool: + def ranked(self, spec: ServiceSpec) -> bool: return True def fence(self, daemon_id: str) -> None: