Skip to content

pg_autoscaler: Fix divide by zero edge cases - #72321

Merged
SrinivasaBharath merged 1 commit into
ceph:mainfrom
Ericmzhang:wip-autoscaler-div-by-zero
Nov 9, 2026
Merged

SrinivasaBharath merged 1 commit into
ceph:mainfrom
Ericmzhang:wip-autoscaler-div-by-zero

Conversation

@Ericmzhang

@Ericmzhang Ericmzhang commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

-Fix divide by zero edge cases that occur when the pg target is zero (due to overlapping roots and small mon_target_pg_per_osd value where pg_target += mon_target_pg_per_osd // len(roots) = 0. The reported ratio is set to 0 if calculating the ratio would cause a divide by zero

-Return early for the case of bulk pools that have used_ratio > even_ratio and the remaining pg budget is 0 (leads to a divide by zero)

  • Add unit tests and teuthology test covering the above cases

Fixes: https://tracker.ceph.com/issues/81130

Signed-off-by: Eric Zhang [email protected]

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@Ericmzhang
Ericmzhang requested a review from a team as a code owner October 1, 2026 23:32
@Ericmzhang
Ericmzhang force-pushed the wip-autoscaler-div-by-zero branch 2 times, most recently from 9232fb9 to 05d8919 Compare October 1, 2026 23:36
@kamoltat

kamoltat commented Oct 2, 2026

Copy link
Copy Markdown
Member

@Ericmzhang Please add Fixes: https://tracker.ceph.com/issues/81130 to commit message, thanks!

@kamoltat kamoltat added the needs-umbrella-backport This PR should be backported to Umbrella label Oct 2, 2026

@kamoltat kamoltat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM thanks for making the change


assert pg_total is not None
final_ratio = final_pool_pg_target / pg_total
final_ratio = final_pool_pg_target / pg_total if pg_total else 0.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ack!

# third pass we calculate the final_pool_pg_target
# for pools that have used_ratio > even_ratio
# and we keep track of even pools to be used in third pass
if pg_left == 0:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ack

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath20-testing-20261002.224634-main.

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

-Fix divide by zero edge cases that occur when the pg target is zero (due to
overlapping roots and small mon_target_pg_per_osd value where
pg_target += mon_target_pg_per_osd // len(roots) = 0. Setting the reported ratio as 0
if calculating the ratio would cause a divide by zero

-Return early for the case of bulk pools that have used_ratio > even_ratio and the remaining
pg budget is 0 (leads to a divide by zero)

Fixes: https://tracker.ceph.com/issues/81130

Signed-off-by: Eric Zhang <[email protected]>
@Ericmzhang
Ericmzhang force-pushed the wip-autoscaler-div-by-zero branch from 4c93663 to 728153f Compare October 16, 2026 15:08
@adam-lj

adam-lj commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

@SrinivasaBharath
SrinivasaBharath merged commit ac9e87c into ceph:main Nov 9, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants