From: Sebastian Wagner Date: Mon, 6 Jan 2020 13:07:55 +0000 (+0100) Subject: mgr/orchestrator_cli: _update_mons require host spec only X-Git-Tag: v15.1.0~310^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ce2010c4e3b8a817699cdc1087f51f800995eaa4;p=ceph.git mgr/orchestrator_cli: _update_mons require host spec only * `mgr/cephadm` requres a host spec right now * `mgr/rook` only supports `spec.count` right now Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 2821ce389a01..b68b52c91d02 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1148,6 +1148,10 @@ class CephadmOrchestrator(MgrModule, orchestrator.Orchestrator): """ Adjust the number of cluster managers. """ + 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 = NodeAssignment(spec=spec, get_hosts_func=self._get_hosts, service_type='mon').load() return self._update_mons(spec) diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index f437349cf1bd..64391f428ba7 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -622,15 +622,10 @@ Usage: "name=label,type=CephString,req=false", 'Update the number of monitor instances') def _update_mons(self, num=None, hosts=[], label=None): - - if hosts or label: - placement = orchestrator.PlacementSpec(label=label, count=num, hosts=hosts) - else: + if not num and not hosts and not label: # Improve Error message. Point to parse_host_spec examples - raise orchestrator.OrchestratorValidationError("Mons need a host spec. (host, network, name(opt))") - # TODO: Scaling without a HostSpec doesn't work right now. - # we need network autodetection for that. - # placement = orchestrator.PlacementSpec(count=num) + raise orchestrator.OrchestratorValidationError("Mons need a placement spec. (num, host, network, name(opt))") + placement = orchestrator.PlacementSpec(label=label, count=num, hosts=hosts) placement.validate() spec = orchestrator.StatefulServiceSpec(placement=placement) diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index a04f7732c506..38ead7c40d9a 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -338,8 +338,9 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): ) def update_mons(self, spec): - if spec.placement.nodes: - raise RuntimeError("Host list is not supported by rook.") + # type: (orchestrator.StatefulServiceSpec) -> RookCompletion + if spec.placement.hosts or spec.placement.label: + raise RuntimeError("Host list or label is not supported by rook.") return write_completion( lambda: self.rook_cluster.update_mon_count(spec.placement.count),