]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: default check ok-to-stop when restarting daemons through orchestrator
authorJoshua Blanch <joshua.blanch@clyso.com>
Wed, 19 Feb 2025 16:56:31 +0000 (16:56 +0000)
committerJoshua Blanch <joshua.blanch@clyso.com>
Thu, 20 Feb 2025 00:50:35 +0000 (00:50 +0000)
Signed-off-by: Joshua Blanch <joshua.blanch@clyso.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/orchestrator/_interface.py
src/pybind/mgr/orchestrator/module.py

index 57574c02196e1ee0f4432fb0c2023a57f0617d40..74053a57b0c9ebf2551dd07a9212a89e2bf42b5f 100644 (file)
@@ -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']:
index d2002f9fc0e7f7580e5312714a9c2e2b99c791bf..4a62154217985160f13494028346a034d13eb6de 100644 (file)
@@ -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.
 
index d3e278c33334b023c34e760f3df4a7c351e1f37f..888de0bfdb6d84dd8e9bb05072cfaa3be1a74c91 100644 (file)
@@ -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())