]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: add placementspec for which hosts get ceph.conf
authorSage Weil <sage@newdream.net>
Tue, 20 Apr 2021 16:58:13 +0000 (12:58 -0400)
committerSage Weil <sage@newdream.net>
Tue, 4 May 2021 16:21:57 +0000 (11:21 -0500)
Add a config option to control which hosts (by default, *) get a
ceph.conf (if the bool manage_etc_ceph_ceph_conf option is enabled).

We don't modify the existing option because changing a type makes for a
messy migration: we have to sort out which section the config option is
in to change it.  Also, a simple on/off which is more friendly than
specifying "*" to enable something.

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit f1096030d9b6caeeaf7c1982b770b5f3fbe913bc)

doc/cephadm/operations.rst
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/serve.py

index da8e14999d707ccaf8d4eee6bf46f53eb4030a1d..eac9f2e00b9d6e18d14785df2eeb9a32101c4d0f 100644 (file)
@@ -318,6 +318,14 @@ hosts, please enable this by running::
 
   ceph config set mgr mgr/cephadm/manage_etc_ceph_ceph_conf true
 
+If enabled, by default cephadm will update ``ceph.conf`` on all cluster hosts. To
+change the set of hosts that get a managed config file, you can update the
+``mgr/cephadm/manage_etc_ceph_ceph_conf_hosts`` setting to a different placement
+spec (see :ref:`orchestrator-cli-placement-spec`).  For example, to limit config
+file updates to hosts with the ``foo`` label::
+
+  ceph config set mgr mgr/cephadm/manage_etc_ceph_ceph_conf_host label:foo
+
 To set up an initial configuration before bootstrapping
 the cluster, create an initial ``ceph.conf`` file. For example::
 
index 68b501a2c76c6758f4afc32b8fd8a26940d81980..7eb1a17d811c1ebbe28295a53e0d00a8953d1d8e 100644 (file)
@@ -283,6 +283,12 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
             default=False,
             desc='Manage and own /etc/ceph/ceph.conf on the hosts.',
         ),
+        Option(
+            'manage_etc_ceph_ceph_conf_hosts',
+            type='str',
+            default='*',
+            desc='PlacementSpec describing on which hosts to manage /etc/ceph/ceph.conf',
+        ),
         Option(
             'registry_url',
             type='str',
@@ -366,6 +372,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
             self.migration_current: Optional[int] = None
             self.config_dashboard = True
             self.manage_etc_ceph_ceph_conf = True
+            self.manage_etc_ceph_ceph_conf_hosts = '*'
             self.registry_url: Optional[str] = None
             self.registry_username: Optional[str] = None
             self.registry_password: Optional[str] = None
index d39d27c8e9c8d01cf53824e93eaa8bc1420389f2..b04877dd0ecff72f43628dd3ebe42635d30a9f3d 100644 (file)
@@ -14,7 +14,7 @@ except ImportError:
 
 from ceph.deployment import inventory
 from ceph.deployment.drive_group import DriveGroupSpec
-from ceph.deployment.service_spec import ServiceSpec, IngressSpec, CustomContainerSpec
+from ceph.deployment.service_spec import ServiceSpec, IngressSpec, CustomContainerSpec, PlacementSpec
 from ceph.utils import str_to_datetime, datetime_now
 
 import orchestrator
@@ -131,6 +131,21 @@ class CephadmServe:
         bad_hosts = []
         failures = []
 
+        etc_ceph_ceph_conf_hosts = []
+        if self.mgr.manage_etc_ceph_ceph_conf:
+            try:
+                pspec = PlacementSpec.from_string(self.mgr.manage_etc_ceph_ceph_conf_hosts)
+                ha = HostAssignment(
+                    spec=ServiceSpec('mon', placement=pspec),
+                    hosts=self.mgr._schedulable_hosts(),
+                    daemons=[],
+                    networks=self.mgr.cache.networks,
+                )
+                all_slots, _, _ = ha.place()
+                etc_ceph_ceph_conf_hosts = [s.hostname for s in all_slots]
+            except Exception as e:
+                self.mgr.log.warning(f'unable to calc conf hosts: {self.mgr.manage_etc_ceph_ceph_conf_hosts}: {e}')
+
         @forall_hosts
         def refresh(host: str) -> None:
 
@@ -173,7 +188,10 @@ class CephadmServe:
                 if r:
                     failures.append(r)
 
-            if self.mgr.cache.host_needs_new_etc_ceph_ceph_conf(host):
+            if (
+                host in etc_ceph_ceph_conf_hosts
+                and self.mgr.cache.host_needs_new_etc_ceph_ceph_conf(host)
+            ):
                 self.log.debug(f"deploying new /etc/ceph/ceph.conf on `{host}`")
                 r = self._deploy_etc_ceph_ceph_conf(host)
                 if r: