.. py:currentmodule:: orchestrator
-Monitors
+Services
--------
-.. automethod:: Orchestrator.add_mon
+.. automethod:: Orchestrator.add_daemon
.. automethod:: Orchestrator.apply_mon
-
-Stateless Services
-------------------
-
-.. automethod:: Orchestrator.add_mgr
.. automethod:: Orchestrator.apply_mgr
-.. automethod:: Orchestrator.add_mds
.. automethod:: Orchestrator.apply_mds
-.. automethod:: Orchestrator.add_rbd_mirror
.. automethod:: Orchestrator.apply_rbd_mirror
.. py:currentmodule:: ceph.deployment.service_spec
.. py:currentmodule:: orchestrator
-.. automethod:: Orchestrator.add_rgw
.. automethod:: Orchestrator.apply_rgw
.. py:currentmodule:: ceph.deployment.service_spec
.. py:currentmodule:: orchestrator
-.. automethod:: Orchestrator.add_nfs
.. automethod:: Orchestrator.apply_nfs
Upgrades
from orchestrator.module import to_format, Format
from orchestrator import OrchestratorError, OrchestratorValidationError, HostSpec, \
- CLICommandMeta, DaemonDescription, DaemonDescriptionStatus, handle_orch_error
+ CLICommandMeta, DaemonDescription, DaemonDescriptionStatus, handle_orch_error, \
+ service_to_daemon_types
from orchestrator._interface import GenericSpec
from orchestrator._interface import daemon_type_to_service
return create_func_map(args)
@handle_orch_error
- def apply_mon(self, spec: ServiceSpec) -> str:
- return self._apply(spec)
-
- @handle_orch_error
- def add_mon(self, spec):
- # type: (ServiceSpec) -> List[str]
- return self._add_daemon('mon', spec)
+ def add_daemon(self, spec: ServiceSpec) -> List[str]:
+ ret: List[str] = []
+ for d_type in service_to_daemon_types(spec.service_type):
+ ret.extend(self._add_daemon(d_type, spec))
+ return ret
@handle_orch_error
- def add_mgr(self, spec):
- # type: (ServiceSpec) -> List[str]
- return self._add_daemon('mgr', spec)
+ def apply_mon(self, spec: ServiceSpec) -> str:
+ return self._apply(spec)
def _apply(self, spec: GenericSpec) -> str:
if spec.service_type == 'host':
def apply_mgr(self, spec: ServiceSpec) -> str:
return self._apply(spec)
- @handle_orch_error
- def add_mds(self, spec: ServiceSpec) -> List[str]:
- return self._add_daemon('mds', spec)
-
@handle_orch_error
def apply_mds(self, spec: ServiceSpec) -> str:
return self._apply(spec)
- @handle_orch_error
- def add_rgw(self, spec: ServiceSpec) -> List[str]:
- return self._add_daemon('rgw', spec)
-
@handle_orch_error
def apply_rgw(self, spec: ServiceSpec) -> str:
return self._apply(spec)
def apply_ha_rgw(self, spec: ServiceSpec) -> str:
return self._apply(spec)
- @handle_orch_error
- def add_iscsi(self, spec):
- # type: (ServiceSpec) -> List[str]
- return self._add_daemon('iscsi', spec)
-
@handle_orch_error
def apply_iscsi(self, spec: ServiceSpec) -> str:
return self._apply(spec)
- @handle_orch_error
- def add_rbd_mirror(self, spec: ServiceSpec) -> List[str]:
- return self._add_daemon('rbd-mirror', spec)
-
@handle_orch_error
def apply_rbd_mirror(self, spec: ServiceSpec) -> str:
return self._apply(spec)
- @handle_orch_error
- def add_nfs(self, spec: ServiceSpec) -> List[str]:
- return self._add_daemon('nfs', spec)
-
@handle_orch_error
def apply_nfs(self, spec: ServiceSpec) -> str:
return self._apply(spec)
# type: () -> str
return self.get('mgr_map').get('services', {}).get('dashboard', '')
- @handle_orch_error
- def add_prometheus(self, spec: ServiceSpec) -> List[str]:
- return self._add_daemon('prometheus', spec)
-
@handle_orch_error
def apply_prometheus(self, spec: ServiceSpec) -> str:
return self._apply(spec)
- @handle_orch_error
- def add_node_exporter(self, spec):
- # type: (ServiceSpec) -> List[str]
- return self._add_daemon('node-exporter', spec)
-
@handle_orch_error
def apply_node_exporter(self, spec: ServiceSpec) -> str:
return self._apply(spec)
- @handle_orch_error
- def add_crash(self, spec):
- # type: (ServiceSpec) -> List[str]
- return self._add_daemon('crash', spec)
-
@handle_orch_error
def apply_crash(self, spec: ServiceSpec) -> str:
return self._apply(spec)
- @handle_orch_error
- def add_grafana(self, spec):
- # type: (ServiceSpec) -> List[str]
- return self._add_daemon('grafana', spec)
-
@handle_orch_error
def apply_grafana(self, spec: ServiceSpec) -> str:
return self._apply(spec)
- @handle_orch_error
- def add_alertmanager(self, spec):
- # type: (ServiceSpec) -> List[str]
- return self._add_daemon('alertmanager', spec)
-
@handle_orch_error
def apply_alertmanager(self, spec: ServiceSpec) -> str:
return self._apply(spec)
- @handle_orch_error
- def add_container(self, spec: ServiceSpec) -> List[str]:
- return self._add_daemon('container', spec)
-
@handle_orch_error
def apply_container(self, spec: ServiceSpec) -> str:
return self._apply(spec)
- @handle_orch_error
- def add_cephadm_exporter(self, spec):
- # type: (ServiceSpec) -> List[str]
- return self._add_daemon('cephadm-exporter',
- spec)
-
@handle_orch_error
def apply_cephadm_exporter(self, spec: ServiceSpec) -> str:
return self._apply(spec)
@contextmanager
-def with_daemon(cephadm_module: CephadmOrchestrator, spec: ServiceSpec, meth, host: str):
+def with_daemon(cephadm_module: CephadmOrchestrator, spec: ServiceSpec, host: str):
spec.placement = PlacementSpec(hosts=[host], count=1)
- c = meth(cephadm_module, spec)
+ c = cephadm_module.add_daemon(spec)
[out] = wait(cephadm_module, c)
match_glob(out, f"Deployed {spec.service_name()}.* on host '{host}'")
c = cephadm_module.list_daemons(refresh=True)
assert wait(cephadm_module, c) == []
with with_service(cephadm_module, ServiceSpec('mds', 'name', unmanaged=True)) as _, \
- with_daemon(cephadm_module, ServiceSpec('mds', 'name'), CephadmOrchestrator.add_mds, 'test') as _:
+ with_daemon(cephadm_module, ServiceSpec('mds', 'name'), 'test') as _:
c = cephadm_module.list_daemons()
cephadm_module.service_cache_timeout = 10
with with_host(cephadm_module, 'test'):
with with_service(cephadm_module, RGWSpec(service_id='myrgw.foobar', unmanaged=True)) as _, \
- with_daemon(cephadm_module, RGWSpec(service_id='myrgw.foobar'), CephadmOrchestrator.add_rgw, 'test') as daemon_id:
+ with_daemon(cephadm_module, RGWSpec(service_id='myrgw.foobar'), 'test') as daemon_id:
c = cephadm_module.daemon_action('redeploy', 'rgw.' + daemon_id)
assert wait(cephadm_module,
cephadm_module.service_cache_timeout = 10
with with_host(cephadm_module, 'test'):
with with_service(cephadm_module, RGWSpec(service_id='myrgw.foobar', unmanaged=True)) as _, \
- with_daemon(cephadm_module, RGWSpec(service_id='myrgw.foobar'), CephadmOrchestrator.add_rgw, 'test') as daemon_id:
+ with_daemon(cephadm_module, RGWSpec(service_id='myrgw.foobar'), 'test') as daemon_id:
with mock.patch('ceph_module.BaseMgrModule._ceph_send_command') as _ceph_send_command:
_ceph_send_command.side_effect = Exception("myerror")
with with_host(cephadm_module, 'test'):
with with_service(cephadm_module, ServiceSpec(service_type='mon', unmanaged=True)):
ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1)
- c = cephadm_module.add_mon(ServiceSpec('mon', placement=ps))
+ c = cephadm_module.add_daemon(ServiceSpec('mon', placement=ps))
assert wait(cephadm_module, c) == ["Deployed mon.a on host 'test'"]
with pytest.raises(OrchestratorError, match="Must set public_network config option or specify a CIDR network,"):
ps = PlacementSpec(hosts=['test'], count=1)
- c = cephadm_module.add_mon(ServiceSpec('mon', placement=ps))
+ c = cephadm_module.add_daemon(ServiceSpec('mon', placement=ps))
wait(cephadm_module, c)
@mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('[]'))
with with_host(cephadm_module, 'host2'):
with with_service(cephadm_module, RGWSpec(service_id="foo", unmanaged=True)):
ps = PlacementSpec(hosts=['host1'], count=1)
- c = cephadm_module.add_rgw(
+ c = cephadm_module.add_daemon(
RGWSpec(service_id="foo", placement=ps))
[out] = wait(cephadm_module, c)
match_glob(out, "Deployed rgw.foo.* on host 'host1'")
assert out == ["Removed rgw.myrgw.myhost.myid from host 'test'"]
@pytest.mark.parametrize(
- "spec, meth",
+ "spec",
[
- (ServiceSpec('crash'), CephadmOrchestrator.add_crash),
- (ServiceSpec('prometheus'), CephadmOrchestrator.add_prometheus),
- (ServiceSpec('grafana'), CephadmOrchestrator.add_grafana),
- (ServiceSpec('node-exporter'), CephadmOrchestrator.add_node_exporter),
- (ServiceSpec('alertmanager'), CephadmOrchestrator.add_alertmanager),
- (ServiceSpec('rbd-mirror'), CephadmOrchestrator.add_rbd_mirror),
- (ServiceSpec('mds', service_id='fsname'), CephadmOrchestrator.add_mds),
- (RGWSpec(rgw_realm='realm', rgw_zone='zone'), CephadmOrchestrator.add_rgw),
- (RGWSpec(service_id="foo"), CephadmOrchestrator.add_rgw),
- (ServiceSpec('cephadm-exporter'), CephadmOrchestrator.add_cephadm_exporter),
+ ServiceSpec('crash'),
+ ServiceSpec('prometheus'),
+ ServiceSpec('grafana'),
+ ServiceSpec('node-exporter'),
+ ServiceSpec('alertmanager'),
+ ServiceSpec('rbd-mirror'),
+ ServiceSpec('mds', service_id='fsname'),
+ RGWSpec(rgw_realm='realm', rgw_zone='zone'),
+ RGWSpec(service_id="foo"),
+ ServiceSpec('cephadm-exporter'),
]
)
@mock.patch("cephadm.serve.CephadmServe._deploy_cephadm_binary", _deploy_cephadm_binary('test'))
@mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('{}'))
- def test_daemon_add(self, spec: ServiceSpec, meth, cephadm_module):
+ def test_daemon_add(self, spec: ServiceSpec, cephadm_module):
unmanaged_spec = ServiceSpec.from_json(spec.to_json())
unmanaged_spec.unmanaged = True
with with_host(cephadm_module, 'test'):
with with_service(cephadm_module, unmanaged_spec):
- with with_daemon(cephadm_module, spec, meth, 'test'):
+ with with_daemon(cephadm_module, spec, 'test'):
pass
@mock.patch("cephadm.serve.CephadmServe._run_cephadm")
with with_service(cephadm_module, spec):
_run_cephadm.side_effect = OrchestratorError('fail')
with pytest.raises(OrchestratorError):
- wait(cephadm_module, cephadm_module.add_mgr(spec))
+ wait(cephadm_module, cephadm_module.add_daemon(spec))
cephadm_module.assert_issued_mon_command({
'prefix': 'auth rm',
'entity': 'mgr.x',
unmanaged_spec = ServiceSpec.from_json(spec.to_json())
unmanaged_spec.unmanaged = True
with with_service(cephadm_module, unmanaged_spec):
- c = cephadm_module.add_nfs(spec)
+ c = cephadm_module.add_daemon(spec)
[out] = wait(cephadm_module, c)
match_glob(out, "Deployed nfs.name.* on host 'test'")
unmanaged_spec.unmanaged = True
with with_service(cephadm_module, unmanaged_spec):
- c = cephadm_module.add_iscsi(spec)
+ c = cephadm_module.add_daemon(spec)
[out] = wait(cephadm_module, c)
match_glob(out, "Deployed iscsi.name.* on host 'test'")
"""
fuse = False
- @staticmethod
+ @ staticmethod
def has_connection():
return False
def import_module(self, *args, **kargs):
return mock.Mock()
- @staticmethod
+ @ staticmethod
def exit():
pass
"""Zap/Erase a device (DESTROYS DATA)"""
raise NotImplementedError()
- def add_mon(self, spec: ServiceSpec) -> OrchResult[List[str]]:
- """Create mon daemon(s)"""
+ def add_daemon(self, spec: ServiceSpec) -> OrchResult[List[str]]:
+ """Create daemons daemon(s) for unmanaged services"""
raise NotImplementedError()
def apply_mon(self, spec: ServiceSpec) -> OrchResult[str]:
"""Update mon cluster"""
raise NotImplementedError()
- def add_mgr(self, spec: ServiceSpec) -> OrchResult[List[str]]:
- """Create mgr daemon(s)"""
- raise NotImplementedError()
-
def apply_mgr(self, spec: ServiceSpec) -> OrchResult[str]:
"""Update mgr cluster"""
raise NotImplementedError()
- def add_mds(self, spec: ServiceSpec) -> OrchResult[List[str]]:
- """Create MDS daemon(s)"""
- raise NotImplementedError()
-
def apply_mds(self, spec: ServiceSpec) -> OrchResult[str]:
"""Update MDS cluster"""
raise NotImplementedError()
- def add_rgw(self, spec: RGWSpec) -> OrchResult[List[str]]:
- """Create RGW daemon(s)"""
- raise NotImplementedError()
-
def apply_rgw(self, spec: RGWSpec) -> OrchResult[str]:
"""Update RGW cluster"""
raise NotImplementedError()
"""Update ha-rgw daemons"""
raise NotImplementedError()
- def add_rbd_mirror(self, spec: ServiceSpec) -> OrchResult[List[str]]:
- """Create rbd-mirror daemon(s)"""
- raise NotImplementedError()
-
def apply_rbd_mirror(self, spec: ServiceSpec) -> OrchResult[str]:
"""Update rbd-mirror cluster"""
raise NotImplementedError()
- def add_nfs(self, spec: NFSServiceSpec) -> OrchResult[List[str]]:
- """Create NFS daemon(s)"""
- raise NotImplementedError()
-
def apply_nfs(self, spec: NFSServiceSpec) -> OrchResult[str]:
"""Update NFS cluster"""
raise NotImplementedError()
- def add_iscsi(self, spec: IscsiServiceSpec) -> OrchResult[List[str]]:
- """Create iscsi daemon(s)"""
- raise NotImplementedError()
-
def apply_iscsi(self, spec: IscsiServiceSpec) -> OrchResult[str]:
"""Update iscsi cluster"""
raise NotImplementedError()
- def add_prometheus(self, spec: ServiceSpec) -> OrchResult[List[str]]:
- """Create new prometheus daemon"""
- raise NotImplementedError()
-
def apply_prometheus(self, spec: ServiceSpec) -> OrchResult[str]:
"""Update prometheus cluster"""
raise NotImplementedError()
- def add_node_exporter(self, spec: ServiceSpec) -> OrchResult[List[str]]:
- """Create a new Node-Exporter service"""
- raise NotImplementedError()
-
def apply_node_exporter(self, spec: ServiceSpec) -> OrchResult[str]:
"""Update existing a Node-Exporter daemon(s)"""
raise NotImplementedError()
- def add_crash(self, spec: ServiceSpec) -> OrchResult[List[str]]:
- """Create a new crash service"""
- raise NotImplementedError()
-
def apply_crash(self, spec: ServiceSpec) -> OrchResult[str]:
"""Update existing a crash daemon(s)"""
raise NotImplementedError()
- def add_grafana(self, spec: ServiceSpec) -> OrchResult[List[str]]:
- """Create a new grafana service"""
- raise NotImplementedError()
-
def apply_grafana(self, spec: ServiceSpec) -> OrchResult[str]:
"""Update existing a grafana service"""
raise NotImplementedError()
- def add_alertmanager(self, spec: ServiceSpec) -> OrchResult[List[str]]:
- """Create a new AlertManager service"""
- raise NotImplementedError()
-
def apply_alertmanager(self, spec: ServiceSpec) -> OrchResult[str]:
"""Update an existing AlertManager daemon(s)"""
raise NotImplementedError()
- def add_cephadm_exporter(self, spec: ServiceSpec) -> OrchResult[List[str]]:
- """Create a new cephadm exporter daemon"""
- raise NotImplementedError()
-
def apply_cephadm_exporter(self, spec: ServiceSpec) -> OrchResult[str]:
"""Update an existing cephadm exporter daemon"""
raise NotImplementedError()
return self._daemon_add_misc(spec)
def _daemon_add_misc(self, spec: ServiceSpec) -> HandleCommandResult:
- daemon_type = ServiceType(spec.service_type)
-
- if daemon_type == ServiceType.mon:
- completion = self.add_mon(spec)
- elif daemon_type == ServiceType.mgr:
- completion = self.add_mgr(spec)
- elif daemon_type == ServiceType.rbd_mirror:
- completion = self.add_rbd_mirror(spec)
- elif daemon_type == ServiceType.crash:
- completion = self.add_crash(spec)
- elif daemon_type == ServiceType.alertmanager:
- completion = self.add_alertmanager(spec)
- elif daemon_type == ServiceType.grafana:
- completion = self.add_grafana(spec)
- elif daemon_type == ServiceType.node_exporter:
- completion = self.add_node_exporter(spec)
- elif daemon_type == ServiceType.prometheus:
- completion = self.add_prometheus(spec)
- elif daemon_type == ServiceType.mds:
- completion = self.add_mds(spec)
- elif daemon_type == ServiceType.rgw:
- completion = self.add_rgw(cast(RGWSpec, spec))
- elif daemon_type == ServiceType.nfs:
- completion = self.add_nfs(cast(NFSServiceSpec, spec))
- elif daemon_type == ServiceType.iscsi:
- completion = self.add_iscsi(cast(IscsiServiceSpec, spec))
- elif daemon_type == ServiceType.cephadm_exporter:
- completion = self.add_cephadm_exporter(spec)
- else:
- tp = type(daemon_type)
- raise OrchestratorValidationError(f'unknown daemon type `{tp}`')
-
+ completion = self.add_daemon(spec)
raise_if_exception(completion)
return HandleCommandResult(stdout=completion.result_str())
return 'done'
@handle_orch_error
- def add_nfs(self, spec):
- # type: (NFSServiceSpec) -> List[str]
- assert isinstance(spec.pool, str)
+ def add_daemon(self, spec: ServiceSpec):
return [spec.one_line_str()]
@handle_orch_error
def apply_nfs(self, spec):
return spec.one_line_str()
- @handle_orch_error
- def add_iscsi(self, spec):
- # type: (IscsiServiceSpec) -> List[str]
- return [spec.one_line_str()]
-
@handle_orch_error
def apply_iscsi(self, spec):
# type: (IscsiServiceSpec) -> str
return spec.one_line_str()
- @handle_orch_error
- def add_mds(self, spec):
- return 'done'
-
- @handle_orch_error
- def add_rgw(self, spec):
- return 'done'
-
@handle_orch_error
def get_hosts(self):
if self._inventory: