]> 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)
committerSage Weil <sage@newdream.net>
Fri, 5 Nov 2021 23:25:16 +0000 (19:25 -0400)
These failures are normal and expected; they should not pollute the log.

Signed-off-by: Sage Weil <sage@newdream.net>
src/pybind/mgr/cephadm/services/osd.py
src/pybind/mgr/cephadm/tests/test_osd_removal.py

index 775d296911ffa5d6d707b72d63bf5358475f362e..42e8f391aef4f8e02d476f9343ebc986e751f6bf 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)