]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: apply: fill in default placement if none is provided 33808/head
authorSage Weil <sage@redhat.com>
Mon, 9 Mar 2020 02:17:47 +0000 (21:17 -0500)
committerSage Weil <sage@redhat.com>
Mon, 9 Mar 2020 02:19:52 +0000 (21:19 -0500)
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 <sage@redhat.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/orchestrator/_interface.py

index 945f0c3a6668e13746fee3377d8b5da945899660..3ccf8b70c2188d548c17b42a5e3f8404b5ddd5f6 100644 (file)
@@ -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)
index 3f0e5dab5792dea04de262964f8ad9041f37af91..af380d98e5b7c2acb52ae125b37370d53f0cb26a 100644 (file)
@@ -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.