From: Joshua Blanch Date: Wed, 19 Feb 2025 16:56:31 +0000 (+0000) Subject: mgr/cephadm: default check ok-to-stop when restarting daemons through orchestrator X-Git-Tag: v20.0.0~29^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0046eaaa367d4490adc842552a7e2765b4247ce3;p=ceph.git mgr/cephadm: default check ok-to-stop when restarting daemons through orchestrator Signed-off-by: Joshua Blanch --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 57574c02196..74053a57b0c 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2553,7 +2553,7 @@ Then run the following: }) @handle_orch_error - def daemon_action(self, action: str, daemon_name: str, image: Optional[str] = None) -> str: + def daemon_action(self, action: str, daemon_name: str, image: Optional[str] = None, force: bool = False) -> str: d = self.cache.get_daemon(daemon_name) assert d.daemon_type is not None assert d.daemon_id is not None @@ -2563,6 +2563,12 @@ Then run the following: raise OrchestratorError( f'Unable to schedule redeploy for {daemon_name}: No standby MGRs') + if action == 'restart' and not force: + r = service_registry.get_service(daemon_type_to_service( + d.daemon_type)).ok_to_stop([d.daemon_id], force=False) + if r.retval: + raise OrchestratorError(f'Unable to {action} daemon {d.name()}: {r.stderr} \nNote: Warnings can be bypassed with the --force flag') + if action == 'rotate-key': if d.daemon_type not in ['mgr', 'osd', 'mds', 'rgw', 'crash', 'nfs', 'rbd-mirror', 'iscsi']: diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index d2002f9fc0e..4a621542179 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -670,7 +670,7 @@ class Orchestrator(object): # assert action in ["start", "stop", "reload, "restart", "redeploy"] raise NotImplementedError() - def daemon_action(self, action: str, daemon_name: str, image: Optional[str] = None) -> OrchResult[str]: + def daemon_action(self, action: str, daemon_name: str, image: Optional[str] = None, force: bool = False) -> OrchResult[str]: """ Perform an action (start/stop/reload) on a daemon. diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index d3e278c3333..888de0bfdb6 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -1605,11 +1605,11 @@ Usage: return HandleCommandResult(stdout=completion.result_str()) @_cli_write_command('orch daemon') - def _daemon_action(self, action: DaemonAction, name: str) -> HandleCommandResult: + def _daemon_action(self, action: DaemonAction, name: str, force: bool = False) -> HandleCommandResult: """Start, stop, restart, redeploy, reconfig, or rotate-key for a specific daemon""" if '.' not in name: raise OrchestratorError('%s is not a valid daemon name' % name) - completion = self.daemon_action(action.value, name) + completion = self.daemon_action(action.value, name, force=force) raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str())