From 5426f6b2a4da743aeb3c3a446fbfbb69c71f6870 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 5 Nov 2021 14:37:47 -0400 Subject: [PATCH] mgr/cephadm/services/osd: do not log ok-to-stop/safe-to-destroy failures These failures are normal and expected; they should not pollute the log. Signed-off-by: Sage Weil --- src/pybind/mgr/cephadm/services/osd.py | 9 +++++---- src/pybind/mgr/cephadm/tests/test_osd_removal.py | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/cephadm/services/osd.py b/src/pybind/mgr/cephadm/services/osd.py index 775d296911ffa..42e8f391aef4f 100644 --- a/src/pybind/mgr/cephadm/services/osd.py +++ b/src/pybind/mgr/cephadm/services/osd.py @@ -432,7 +432,7 @@ class RemoveUtil(object): 'prefix': "osd ok-to-stop", 'ids': [str(osd.osd_id) for osd in osds] } - return self._run_mon_cmd(cmd_args) + return self._run_mon_cmd(cmd_args, error_ok=True) def set_osd_flag(self, osds: List["OSD"], flag: str) -> bool: base_cmd = f"osd {flag}" @@ -492,7 +492,7 @@ class RemoveUtil(object): """ Queries the safe-to-destroy flag for OSDs """ cmd_args = {'prefix': 'osd safe-to-destroy', 'ids': [str(x) for x in osd_ids]} - return self._run_mon_cmd(cmd_args) + return self._run_mon_cmd(cmd_args, error_ok=True) def destroy_osd(self, osd_id: int) -> bool: """ Destroys an OSD (forcefully) """ @@ -510,14 +510,15 @@ class RemoveUtil(object): } return self._run_mon_cmd(cmd_args) - def _run_mon_cmd(self, cmd_args: dict) -> bool: + def _run_mon_cmd(self, cmd_args: dict, error_ok: bool = False) -> bool: """ Generic command to run mon_command and evaluate/log the results """ ret, out, err = self.mgr.mon_command(cmd_args) if ret != 0: self.mgr.log.debug(f"ran {cmd_args} with mon_command") - self.mgr.log.error(f"cmd: {cmd_args.get('prefix')} failed with: {err}. (errno:{ret})") + if not error_ok: + self.mgr.log.error(f"cmd: {cmd_args.get('prefix')} failed with: {err}. (errno:{ret})") return False self.mgr.log.debug(f"cmd: {cmd_args.get('prefix')} returns: {out}") return True diff --git a/src/pybind/mgr/cephadm/tests/test_osd_removal.py b/src/pybind/mgr/cephadm/tests/test_osd_removal.py index 9347678b84daa..6685fcb2a6003 100644 --- a/src/pybind/mgr/cephadm/tests/test_osd_removal.py +++ b/src/pybind/mgr/cephadm/tests/test_osd_removal.py @@ -84,11 +84,13 @@ class TestOSDRemoval: def test_ok_to_stop(self, rm_util): rm_util.ok_to_stop([MockOSD(1)]) - rm_util._run_mon_cmd.assert_called_with({'prefix': 'osd ok-to-stop', 'ids': ['1']}) + rm_util._run_mon_cmd.assert_called_with({'prefix': 'osd ok-to-stop', 'ids': ['1']}, + error_ok=True) def test_safe_to_destroy(self, rm_util): rm_util.safe_to_destroy([1]) - rm_util._run_mon_cmd.assert_called_with({'prefix': 'osd safe-to-destroy', 'ids': ['1']}) + rm_util._run_mon_cmd.assert_called_with({'prefix': 'osd safe-to-destroy', + 'ids': ['1']}, error_ok=True) def test_destroy_osd(self, rm_util): rm_util.destroy_osd(1) -- 2.39.5