From: Sage Weil Date: Sun, 23 Feb 2020 19:46:08 +0000 (-0600) Subject: mgr/cephadm: remove apply_mon support X-Git-Tag: v15.1.1~281^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a29a78e4e9c732f485e40900c5f00de1804f2d46;p=ceph.git mgr/cephadm: remove apply_mon support Our apply method doesn't support removing mons at this point. And using it for adding mons is just an awkward version of 'daemon add'. Update docs and cephadm.py task accordingly. Signed-off-by: Sage Weil --- diff --git a/doc/bootstrap.rst b/doc/bootstrap.rst index 8c86d2d2bd88..808defd591df 100644 --- a/doc/bootstrap.rst +++ b/doc/bootstrap.rst @@ -118,12 +118,12 @@ either as a simple IP address or as a CIDR network name. To deploy additional monitors,:: - [monitor 1] # ceph orch apply mon ** * [...]* + [monitor 1] # ceph orch daemon add mon * [...]* For example, to deploy a second monitor on ``newhost`` using an IP address in network ``10.1.2.0/24``,:: - [monitor 1] # ceph orch apply mon 2 newhost:10.1.2.0/24 + [monitor 1] # ceph orch daemon add mon newhost:10.1.2.0/24 Deploying OSDs ============== diff --git a/qa/tasks/cephadm.py b/qa/tasks/cephadm.py index e234d17eec1f..2bf39421c624 100644 --- a/qa/tasks/cephadm.py +++ b/qa/tasks/cephadm.py @@ -468,8 +468,7 @@ def ceph_mons(ctx, config): log.info('Adding %s on %s' % (mon, remote.shortname)) num_mons += 1 _shell(ctx, cluster_name, remote, [ - 'ceph', 'orch', 'apply', 'mon', - str(num_mons), + 'ceph', 'orch', 'daemon', 'add', 'mon', remote.shortname + ':' + ctx.ceph[cluster_name].mons[mon] + '=' + id_, ]) ctx.daemons.register_daemon( diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index cb91c8e0629c..2c5122f32ddf 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2050,48 +2050,6 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): orchestrator.servicespec_validate_hosts_have_network_spec(spec) return self._add_daemon('mon', spec, self._create_mon) - def apply_mon(self, spec): - # type: (orchestrator.ServiceSpec) -> orchestrator.Completion - if not spec.placement.hosts and not spec.placement.label: - # Improve Error message. Point to parse_host_spec examples - raise orchestrator.OrchestratorValidationError("Mons need a host spec. (host, network, name(opt))") - - spec = HostAssignment(spec=spec, get_hosts_func=self._get_hosts, service_type='mon').load() - - # current support limited to adding monitors. - mon_map = self.get("mon_map") - num_mons = len(mon_map["mons"]) - if spec.count == num_mons: - return orchestrator.Completion(value="The requested number of monitors exist.") - if spec.count < num_mons: - raise NotImplementedError("Removing monitors is not supported.") - - self.log.debug("Trying to update monitors on: {}".format(spec.placement.hosts)) - # check that all the hosts are registered - [self._require_hosts(host.hostname) for host in spec.placement.hosts] - - # current support requires a network to be specified - orchestrator.servicespec_validate_hosts_have_network_spec(spec) - - daemons = self.cache.get_daemons_by_type('mon') - for _, _, name in spec.placement.hosts: - if name and len([d for d in daemons if d.daemon_id == name]): - raise RuntimeError('name %s alrady exists', name) - - # explicit placement: enough hosts provided? - num_new_mons = spec.count - num_mons - if len(spec.placement.hosts) < num_new_mons: - raise RuntimeError("Error: {} hosts provided, expected {}".format( - len(spec.placement.hosts), num_new_mons)) - self.log.info("creating {} monitors on hosts: '{}'".format( - num_new_mons, ",".join(map(lambda h: ":".join(h), spec.placement.hosts)))) - # TODO: we may want to chain the creation of the monitors so they join - # the quorum one at a time. - args = [] - for host, network, name in spec.placement.hosts: - args.append((name or host, network, host)) - return self._create_mon(args) - @async_map_completion def _create_mgr(self, mgr_id, host): """ diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 967a9606f6c7..36a9f7f1c677 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -137,12 +137,12 @@ class TestCephadm(object): def test_mon_update(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1) - c = cephadm_module.apply_mon(ServiceSpec(placement=ps)) + c = cephadm_module.add_mon(ServiceSpec(placement=ps)) assert wait(cephadm_module, c) == ["Deployed mon.a on host 'test'"] with pytest.raises(OrchestratorError, match="is missing a network spec"): ps = PlacementSpec(hosts=['test'], count=1) - c = cephadm_module.apply_mon(ServiceSpec(placement=ps)) + c = cephadm_module.add_mon(ServiceSpec(placement=ps)) wait(cephadm_module, c) @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('[]'))