From: Sage Weil Date: Mon, 9 Mar 2020 02:17:47 +0000 (-0500) Subject: mgr/cephadm: apply: fill in default placement if none is provided X-Git-Tag: v15.1.1~60^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F33808%2Fhead;p=ceph.git mgr/cephadm: apply: fill in default placement if none is provided Most stateless daemons get 2x (so there is a standby). Monitoring items get just 1x. By default we do 5 monitors, which will gracefully degrade to one per host if the cluster has <5 hosts. Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 945f0c3a6668..3ccf8b70c218 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2359,7 +2359,23 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): return self._add_daemon('mgr', spec, self._create_mgr) def _apply(self, spec): - self.log.info('Saving service %s spec' % spec.service_name()) + if spec.placement.is_empty(): + # fill in default placement + defaults = { + 'mon': orchestrator.PlacementSpec(count=5), + 'mgr': orchestrator.PlacementSpec(count=2), + 'mds': orchestrator.PlacementSpec(count=2), + 'rgw': orchestrator.PlacementSpec(count=2), + 'rbd-mirror': orchestrator.PlacementSpec(count=2), + 'grafana': orchestrator.PlacementSpec(count=1), + 'alertmanager': orchestrator.PlacementSpec(count=1), + 'prometheus': orchestrator.PlacementSpec(count=1), + 'node-exporter': orchestrator.PlacementSpec(all_hosts=True), + 'crash': orchestrator.PlacementSpec(all_hosts=True), + } + spec.placement = defaults[spec.service_type] + self.log.info('Saving service %s spec with placement %s' % ( + spec.service_name(), spec.placement.pretty_str())) self.spec_store.save(spec) self._kick_serve_loop() return trivial_result("Scheduled %s update..." % spec.service_type) diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index 3f0e5dab5792..af380d98e5b7 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -1267,6 +1267,12 @@ class PlacementSpec(object): self.count = count # type: Optional[int] self.all_hosts = all_hosts # type: bool + def is_empty(self): + return not self.all_hosts and \ + self.label is None and \ + not self.hosts and \ + self.count is None + def set_hosts(self, hosts): # To backpopulate the .hosts attribute when using labels or count # in the orchestrator backend.