From 73532088915b8e7daf4a45d8b7968cdab55de9d1 Mon Sep 17 00:00:00 2001 From: Adam King Date: Wed, 24 Mar 2021 12:29:20 -0400 Subject: [PATCH] mgr/cephadm: place maximum on placement count based on host count Fixes: https://tracker.ceph.com/issues/49960 Signed-off-by: Adam King --- src/pybind/mgr/cephadm/module.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index f5d4307a873..d9855956f26 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -319,6 +319,12 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, default='docker.io', desc='Registry to which we should normalize unqualified image names', ), + Option( + 'max_count_per_host', + type='int', + default=10, + desc='max number of daemons per service per host', + ), ] def __init__(self, *args: Any, **kwargs: Any): @@ -342,6 +348,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, self.daemon_cache_timeout = 0 self.facts_cache_timeout = 0 self.host_check_interval = 0 + self.max_count_per_host = 0 self.mode = '' self.container_image_base = '' self.container_image_prometheus = '' @@ -2148,6 +2155,23 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, raise OrchestratorError('cannot scale %s service below 1' % ( spec.service_type)) + host_count = len(self.inventory.keys()) + max_count = self.max_count_per_host + + if spec.placement.count is not None: + if spec.service_type in ['mon', 'mgr']: + if spec.placement.count > max(5, host_count): + raise OrchestratorError( + (f'The maximum number of {spec.service_type} daemons allowed with {host_count} hosts is {max(5, host_count)}.')) + elif spec.service_type != 'osd': + if spec.placement.count > (max_count * host_count): + raise OrchestratorError((f'The maximum number of {spec.service_type} daemons allowed with {host_count} hosts is {host_count*max_count} ({host_count}x{max_count}).' + + ' This limit can be adjusted by changing the mgr/cephadm/max_count_per_host config option')) + + if spec.placement.count_per_host is not None and spec.placement.count_per_host > max_count and spec.service_type != 'osd': + raise OrchestratorError((f'The maximum count_per_host allowed is {max_count}.' + + ' This limit can be adjusted by changing the mgr/cephadm/max_count_per_host config option')) + HostAssignment( spec=spec, hosts=self.inventory.all_specs(), # All hosts, even those without daemon refresh