From 4a3347c1c6e447afacef08adc5316759d7516f29 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 20 Apr 2021 12:58:13 -0400 Subject: [PATCH] mgr/cephadm: add placementspec for which hosts get ceph.conf 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 (cherry picked from commit f1096030d9b6caeeaf7c1982b770b5f3fbe913bc) --- doc/cephadm/operations.rst | 8 ++++++++ src/pybind/mgr/cephadm/module.py | 7 +++++++ src/pybind/mgr/cephadm/serve.py | 22 ++++++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/doc/cephadm/operations.rst b/doc/cephadm/operations.rst index da8e14999d707..eac9f2e00b9d6 100644 --- a/doc/cephadm/operations.rst +++ b/doc/cephadm/operations.rst @@ -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:: diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 68b501a2c76c6..7eb1a17d811c1 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -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 diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py index d39d27c8e9c8d..b04877dd0ecff 100644 --- a/src/pybind/mgr/cephadm/serve.py +++ b/src/pybind/mgr/cephadm/serve.py @@ -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: -- 2.39.5