]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: ceph osd status crash with ZeroDivisionError 46696/head
authorNitzan Mordechai <nmordech@redhat.com>
Mon, 24 Jan 2022 10:55:23 +0000 (12:55 +0200)
committerNitzanMordhai <nmordech@redhat.com>
Sun, 19 Nov 2023 11:03:14 +0000 (11:03 +0000)
If stats-update is called a second time within a second, get_rate() fails with
a 'divide by 0' error.
Change the check before the computation, taking into account the fact that
two f.p numbers may differ, but still their diff - when cast into an int - might
be zero.

Fixed: https://tracker.ceph.com/issues/53538
Signed-off-by: Nitzan Mordechai <nmordech@redhat.com>
(cherry picked from commit 140b7ce529f23ae429e71dfc1ad0deef13174e88)

src/pybind/mgr/status/module.py

index 676bc03d9a01f1bb6f5f818c3faa62c37529b2df..d83de859b0959c389bd69a71c188e47678744287 100644 (file)
@@ -43,7 +43,7 @@ class Module(MgrModule):
         data = self.get_counter(daemon_type, daemon_name, stat)[stat]
 
         #self.log.error("get_latest {0} data={1}".format(stat, data))
-        if data and len(data) > 1 and data[-1][0] != data[-2][0]:
+        if data and len(data) > 1 and (int(data[-1][0] - data[-2][0]) != 0):
             return (data[-1][1] - data[-2][1]) // int(data[-1][0] - data[-2][0])
         else:
             return 0