]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Merge pull request #33333 from sebastian-philipp/cephadm-mon-apply-host-no-network
authorSebastian Wagner <sebastian.wagner@suse.com>
Wed, 19 Feb 2020 15:49:17 +0000 (16:49 +0100)
committerGitHub <noreply@github.com>
Wed, 19 Feb 2020 15:49:17 +0000 (16:49 +0100)
mgr/cephadm: mon: Don't show traceback for user errors

Reviewed-by: Sage Weil <sage@redhat.com>
1  2 
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_cephadm.py
src/pybind/mgr/orchestrator/_interface.py

index 954f4d9bcf47b4cfa74df85b19fe3d0ef4d4ba76,fcf5ff10d0cb5ee85721158282b71a6f339f9ca6..9b694bfe2eca519430e0aed586d98b48c3a36a7a
@@@ -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
          """
          [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):