mirror of
https://github.com/ceph/ceph
synced 2025-02-24 03:27:10 +00:00
Merge PR #43821 into master
* refs/pull/43821/head: mgr/cephadm: allow osd spec removal mgr/orchestrator: pass 'force' flag down for remove_service Reviewed-by: Adam King <adking@redhat.com>
This commit is contained in:
commit
9c8d19e7ca
@ -1917,7 +1917,7 @@ Then run the following:
|
||||
return self._remove_daemons(args)
|
||||
|
||||
@handle_orch_error
|
||||
def remove_service(self, service_name: str) -> str:
|
||||
def remove_service(self, service_name: str, force: bool = False) -> str:
|
||||
self.log.info('Remove service %s' % service_name)
|
||||
self._trigger_preview_refresh(service_name=service_name)
|
||||
if service_name in self.spec_store:
|
||||
@ -1925,9 +1925,9 @@ Then run the following:
|
||||
return f'Unable to remove {service_name} service.\n' \
|
||||
f'Note, you might want to mark the {service_name} service as "unmanaged"'
|
||||
|
||||
# Report list of affected OSDs
|
||||
osds_msg = {}
|
||||
if service_name.startswith('osd.'):
|
||||
# Report list of affected OSDs?
|
||||
if not force and service_name.startswith('osd.'):
|
||||
osds_msg = {}
|
||||
for h, dm in self.cache.get_daemons_with_volatile_status():
|
||||
osds_to_remove = []
|
||||
for name, dd in dm.items():
|
||||
@ -1935,23 +1935,17 @@ Then run the following:
|
||||
osds_to_remove.append(str(dd.daemon_id))
|
||||
if osds_to_remove:
|
||||
osds_msg[h] = osds_to_remove
|
||||
|
||||
found = self.spec_store.rm(service_name) or osds_msg
|
||||
if found:
|
||||
self._kick_serve_loop()
|
||||
if osds_msg:
|
||||
return f'The service {service_name} will be deleted once the following OSDs: {osds_msg} ' \
|
||||
f'will be deleted manually.'
|
||||
else:
|
||||
return f'Removed service {service_name}'
|
||||
else:
|
||||
# must be idempotent: still a success.
|
||||
try:
|
||||
self.cache.get_daemon(service_name)
|
||||
return (f'Failed to remove service <{service_name}>. "{service_name}" is the name of a daemon, not a service. '
|
||||
+ 'Running service names can be found with "ceph orch ls"')
|
||||
except OrchestratorError:
|
||||
return f'Failed to remove service. <{service_name}> was not found. Running service names can be found with "ceph orch ls"'
|
||||
msg = ''
|
||||
for h, ls in osds_msg.items():
|
||||
msg += f'\thost {h}: {" ".join([f"osd.{id}" for id in ls])}'
|
||||
raise OrchestratorError(f'If {service_name} is removed then the following OSDs will remain, --force to proceed anyway\n{msg}')
|
||||
|
||||
found = self.spec_store.rm(service_name)
|
||||
if found and service_name.startswith('osd.'):
|
||||
self.spec_store.finally_rm(service_name)
|
||||
self._kick_serve_loop()
|
||||
return f'Removed service {service_name}'
|
||||
|
||||
@handle_orch_error
|
||||
def get_inventory(self, host_filter: Optional[orchestrator.InventoryFilter] = None, refresh: bool = False) -> List[orchestrator.InventoryHost]:
|
||||
|
@ -490,7 +490,7 @@ class Orchestrator(object):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def remove_service(self, service_name: str) -> OrchResult[str]:
|
||||
def remove_service(self, service_name: str, force: bool = False) -> OrchResult[str]:
|
||||
"""
|
||||
Remove a service (a collection of daemons).
|
||||
|
||||
|
@ -1019,7 +1019,7 @@ Usage:
|
||||
"""Remove a service"""
|
||||
if service_name in ['mon', 'mgr'] and not force:
|
||||
raise OrchestratorError('The mon and mgr services cannot be removed')
|
||||
completion = self.remove_service(service_name)
|
||||
completion = self.remove_service(service_name, force=force)
|
||||
raise_if_exception(completion)
|
||||
return HandleCommandResult(stdout=completion.result_str())
|
||||
|
||||
|
@ -463,7 +463,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
|
||||
return num_replicas, leaf_type
|
||||
|
||||
@handle_orch_error
|
||||
def remove_service(self, service_name: str) -> str:
|
||||
def remove_service(self, service_name: str, force: bool = False) -> str:
|
||||
if service_name == 'rbd-mirror':
|
||||
return self.rook_cluster.rm_service('cephrbdmirrors', 'default-rbd-mirror')
|
||||
service_type, service_name = service_name.split('.', 1)
|
||||
|
@ -227,7 +227,7 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator):
|
||||
return 'done'
|
||||
|
||||
@handle_orch_error
|
||||
def remove_service(self, service_name):
|
||||
def remove_service(self, service_name, force = False):
|
||||
assert isinstance(service_name, str)
|
||||
return 'done'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user