Repository navigation
Conversation
Symptom: balance aborts on the first undersized PG it considers as a
move candidate with
File "placementoptimizer.py", line 2702, in __init__
raise RuntimeError(f"not as many roots as shards! root_order={root_order} osds={self.pg_osds}")
RuntimeError: not as many roots as shards! root_order=['default~nvme', 'default~nvme', 'default~nvme'] osds=[32, 4]
raised from PGMoveChecker.__init__ via balance() at line 4809.
Root cause: PGMappings populates `self.pg_mappings[pgid]` directly
from `pginfo["up"]` without normalising its length against
`pool_size`. When CRUSH cannot place all shards (host failure,
exhausted candidates, etc.), the up set is shorter than pool_size,
so `len(pg_osds) != len(root_order)` and PGMoveChecker raises. The
exception propagates up and kills the whole balance run.
Fix: catch RuntimeError around the PGMoveChecker construction in
balance() and `continue` to the next candidate, mirroring the
existing skip pattern used for other unmovable candidates a few
lines above. Recovering an undersized PG is Ceph's job — moving its
remaining shards via upmap is unsafe to plan against, so skipping is
the correct behaviour.
TheJJ
requested changes
May 1, 2026
| # planned upmap is meaningful anyway. | ||
| try: | ||
| try_pg_move = PGMoveChecker(pg_mappings, move_pg) | ||
| except RuntimeError as exc: |
Owner
There was a problem hiding this comment.
we should handle this case properly :) we should not catch all runtime errors, instead we should add a code path that deals with this expected cluster state
Contributor
Author
There was a problem hiding this comment.
Makes sense, I will revise this PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom: balance aborts on the first undersized PG it considers as a move candidate with
raised from PGMoveChecker.init via balance() at line 4809.
Root cause: PGMappings populates
self.pg_mappings[pgid]directly frompginfo["up"]without normalising its length againstpool_size. When CRUSH cannot place all shards (host failure, exhausted candidates, etc.), the up set is shorter than pool_size, solen(pg_osds) != len(root_order)and PGMoveChecker raises. The exception propagates up and kills the whole balance run.Fix: catch RuntimeError around the PGMoveChecker construction in balance() and
continueto the next candidate, mirroring the existing skip pattern used for other unmovable candidates a few lines above. Recovering an undersized PG is Ceph's job — moving its remaining shards via upmap is unsafe to plan against, so skipping is the correct behaviour.Just to be clear, this is one of three AI generated fixes. I collected these three issues over the last few months and wanted to see if claude could find sensible fixes and it looked good to me. If you don't like this, I won't do this again.