]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm/services/osd: do not log ok-to-stop/safe-to-destroy failures
authorSage Weil <sage@newdream.net>
Fri, 5 Nov 2021 18:37:47 +0000 (14:37 -0400)
committerSebastian Wagner <sewagner@redhat.com>
Wed, 17 Nov 2021 10:25:57 +0000 (11:25 +0100)
These failures are normal and expected; they should not pollute the log.

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit 5426f6b2a4da743aeb3c3a446fbfbb69c71f6870)

src/pybind/mgr/cephadm/services/osd.py
src/pybind/mgr/cephadm/tests/test_osd_removal.py

index 86000c042905c5e620972012d58edc9919e0e86b..de7a15c15d621c5f37b77078ad0c29ec0afaa9c9 100644 (file)
@@ -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
index 9347678b84daa5a42ced6af71aa9b833ce87b8c0..6685fcb2a6003d2ee105f0ed9f1b171ed89e3cbb 100644 (file)
@@ -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)