Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pybind/mgr: ceph osd status crash with ZeroDivisionError #44752

Merged
merged 1 commit into from Feb 11, 2022

Conversation

NitzanMordhai
Copy link
Contributor

@NitzanMordhai NitzanMordhai commented Jan 24, 2022

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

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@@ -24,7 +24,7 @@ def get_latest(self, daemon_type: str, daemon_name: str, stat: str) -> int:

def get_rate(self, daemon_type: str, daemon_name: str, stat: str) -> int:
data = self.get_counter(daemon_type, daemon_name, stat)[stat]
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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even if the operator prec. is correct - can you add '()' for legibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. thanks

@ronen-fr
Copy link
Contributor

@NitzanMordhai : I made some changes to the PR message. You might want to consider the revised text
for the commit message.

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>
@NitzanMordhai
Copy link
Contributor Author

@NitzanMordhai : I made some changes to the PR message. You might want to consider the revised text
for the commit message.

@ronen-fr I copied the text changes into the commit

@sebastian-philipp
Copy link
Contributor

have you tried using mgr_util.get_time_series_rates ?

def get_time_series_rates(data: List[Tuple[float, float]]) -> List[Tuple[float, float]]:

@NitzanMordhai
Copy link
Contributor Author

have you tried using mgr_util.get_time_series_rates ?

def get_time_series_rates(data: List[Tuple[float, float]]) -> List[Tuple[float, float]]:

@sebastian-philipp the original function worked fine, the only change was the check before return, the conversion to int caused value lower then 1 to divide by zero

@vshankar vshankar added core and removed cephfs Ceph File System labels Jan 27, 2022
@ronen-fr ronen-fr self-requested a review February 2, 2022 06:34
Copy link
Member

@neha-ojha neha-ojha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/Fixed/Fixes/ in the commit message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants