From: Sebastian Wagner Date: Wed, 19 Feb 2020 15:49:17 +0000 (+0100) Subject: Merge pull request #33333 from sebastian-philipp/cephadm-mon-apply-host-no-network X-Git-Tag: v15.1.1~363 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6f76cde053de9a722810c5f9ff6a0af1713b65e3;p=ceph-ci.git Merge pull request #33333 from sebastian-philipp/cephadm-mon-apply-host-no-network mgr/cephadm: mon: Don't show traceback for user errors Reviewed-by: Sage Weil --- 6f76cde053de9a722810c5f9ff6a0af1713b65e3 diff --cc src/pybind/mgr/cephadm/module.py index 954f4d9bcf4,fcf5ff10d0c..9b694bfe2ec --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@@ -1900,25 -1874,26 +1903,24 @@@ class CephadmOrchestrator(MgrModule, or # type: (orchestrator.ServiceSpec) -> orchestrator.Completion # current support requires a network to be specified - for host, network, _ in spec.placement.hosts: - if not network: - raise RuntimeError("Host '{}' is missing a network spec".format(host)) + orchestrator.servicespec_validate_hosts_have_network_spec(spec) - def add_mons(daemons): - for _, _, name in spec.placement.hosts: - if name and len([d for d in daemons if d.daemon_id == name]): - raise RuntimeError('name %s already exists', name) - - # explicit placement: enough hosts provided? - if len(spec.placement.hosts) < spec.count: - raise RuntimeError("Error: {} hosts provided, expected {}".format( - len(spec.placement.hosts), spec.count)) - self.log.info("creating {} monitors on hosts: '{}'".format( - spec.count, ",".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. - return self._create_mon(spec.placement.hosts) - - return self._get_daemons('mon').then(add_mons) + daemons = self.daemon_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 already exists', name) + + # explicit placement: enough hosts provided? + if len(spec.placement.hosts) < spec.count: + raise RuntimeError("Error: {} hosts provided, expected {}".format( + len(spec.placement.hosts), spec.count)) + self.log.info("creating {} monitors on hosts: '{}'".format( + spec.count, ",".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. + return self._create_mon(spec.placement.hosts) + @async_completion def apply_mon(self, spec): # type: (orchestrator.ServiceSpec) -> orchestrator.Completion """ @@@ -1949,25 -1924,24 +1951,23 @@@ [self._require_hosts(host.hostname) for host in spec.placement.hosts] # current support requires a network to be specified - for host, network, _ in spec.placement.hosts: - if not network: - raise RuntimeError("Host '{}' is missing a network spec".format(host)) + orchestrator.servicespec_validate_hosts_have_network_spec(spec) - def update_mons_with_daemons(daemons): - 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. - return self._create_mon(spec.placement.hosts) - return self._get_daemons('mon').then(update_mons_with_daemons) + daemons = self.daemon_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. + return self._create_mon(spec.placement.hosts) @async_map_completion def _create_mgr(self, mgr_id, host):