From: Sage Weil Date: Fri, 26 Feb 2021 16:50:51 +0000 (-0500) Subject: mgr/cephadm: gather other osds that are safe to stop X-Git-Tag: v17.1.0~2741^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=075d6fc18858bb552ed1a020d7971578680c4104;p=ceph.git mgr/cephadm: gather other osds that are safe to stop Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/services/cephadmservice.py b/src/pybind/mgr/cephadm/services/cephadmservice.py index bfe7ee2ee212b..05a2bd0dd38da 100644 --- a/src/pybind/mgr/cephadm/services/cephadmservice.py +++ b/src/pybind/mgr/cephadm/services/cephadmservice.py @@ -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,