return "Scheduled to remove the following daemons from host '{}'\n{}".format(hostname, daemons_table)
+ @handle_orch_error
+ @host_exists()
+ def stop_drain_host(self, hostname: str) -> str:
+ if not self.inventory.has_label(hostname, '_no_schedule'):
+ raise OrchestratorValidationError(f'The host {hostname} is currently not draining.')
+ self.remove_host_label(hostname, '_no_schedule')
+ self.remove_host_label(hostname, SpecialHostLabels.DRAIN_CONF_KEYRING)
+ # stop osd removal for the host osds which are in to_remove_osds queue
+ osds = [d.daemon_id for d in self.cache.get_daemons_by_type('osd', hostname)]
+ self.stop_remove_osds(osds)
+ return f'Stopped host drain for {hostname}'
+
def trigger_connect_dashboard_rgw(self) -> None:
self.need_connect_dashboard_rgw = True
self.event.set()
cephadm_module.drain_host('host1', force=True, zap_osd_devices=True)
_rm_osds.assert_called_with([], zap=True)
+ @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('[]'))
+ @mock.patch("cephadm.CephadmOrchestrator.stop_remove_osds")
+ @mock.patch("cephadm.inventory.HostCache.get_daemons_by_host", lambda *a, **kw: [])
+ def test_stop_host_drain(self, _stop_rm_osds, cephadm_module):
+ # pass force=true in these tests to bypass _admin label check
+ with with_host(cephadm_module, 'host1', refresh_hosts=False, rm_with_force=True):
+ cephadm_module.drain_host('host1')
+ cephadm_module.stop_drain_host('host1')
+ _stop_rm_osds.assert_called_with([])
+
def test_process_ls_output(self, cephadm_module):
sample_ls_output = """[
{
"""
raise NotImplementedError()
+ def stop_drain_host(self, hostname: str) -> OrchResult[str]:
+ """
+ stop draining daemons of a host
+
+ :param hostname: hostname
+ """
+ raise NotImplementedError()
+
def update_host_addr(self, host: str, addr: str) -> OrchResult[str]:
"""
Update a host's address
raise_if_exception(completion)
return HandleCommandResult(stdout=completion.result_str())
+ @_cli_write_command('orch host drain stop')
+ def _stop_drain_host(self, hostname: str) -> HandleCommandResult:
+ """drain all daemons from a host"""
+ completion = self.stop_drain_host(hostname)
+ raise_if_exception(completion)
+ return HandleCommandResult(stdout=completion.result_str())
+
@_cli_write_command('orch host set-addr')
def _update_set_addr(self, hostname: str, addr: str) -> HandleCommandResult:
"""Update a host address"""