]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: gather other osds that are safe to stop
authorSage Weil <sage@newdream.net>
Fri, 26 Feb 2021 16:50:51 +0000 (11:50 -0500)
committerSage Weil <sage@newdream.net>
Tue, 2 Mar 2021 19:07:32 +0000 (14:07 -0500)
Signed-off-by: Sage Weil <sage@newdream.net>
src/pybind/mgr/cephadm/services/cephadmservice.py

index bfe7ee2ee212bd8cfc80d075c691f20f9b3ac349..05a2bd0dd38da13cd3730a2630de97358ecfbeed 100644 (file)
@@ -222,6 +222,33 @@ class CephadmService(metaclass=ABCMeta):
             except MonCommandFailed as e:
                 logger.warning('Failed to set Dashboard config for %s: %s', service_name, e)
 
+    def ok_to_stop_osd(
+            self,
+            osds: List[str],
+            known: Optional[List[str]] = None,
+            force: bool = False) -> HandleCommandResult:
+        r = HandleCommandResult(*self.mgr.mon_command({
+            'prefix': "osd ok-to-stop",
+            'ids': osds,
+            'max': 16,
+        }))
+        j = None
+        try:
+            j = json.loads(r.stdout)
+        except json.decoder.JSONDecodeError:
+            self.mgr.log.warning("osd ok-to-stop didn't return structured result")
+            raise
+        if r.retval:
+            return r
+        if known is not None and j and j.get('ok_to_stop'):
+            self.mgr.log.debug(f"got {j}")
+            known.extend([f'osd.{x}' for x in j.get('osds', [])])
+        return HandleCommandResult(
+            0,
+            f'{",".join(["osd.%s" % o for o in osds])} {"is" if len(osds) == 1 else "are"} safe to restart',
+            ''
+        )
+
     def ok_to_stop(self,
                    daemon_ids: List[str],
                    force: bool = False,
@@ -234,6 +261,9 @@ class CephadmService(metaclass=ABCMeta):
             logger.info(out)
             return HandleCommandResult(0, out)
 
+        if self.TYPE == 'osd':
+            return self.ok_to_stop_osd(daemon_ids, known, force)
+
         r = HandleCommandResult(*self.mgr.mon_command({
             'prefix': f'{self.TYPE} ok-to-stop',
             'ids': daemon_ids,