Repository navigation
Conversation
calc_pg_upmaps() builds pgs_by_osd from the up sets and osd_weight from the weights under the pool's CRUSH rule, leaving out OSDs whose weight is 0, and calc_deviations() asserts that every OSD in pgs_by_osd has a weight. CRUSH can still map PGs to an OSD with CRUSH weight 0: straw2 returns the first item of a bucket whose items all have weight 0. With a rule that takes several subtrees (take site1 ... emit; take site2 ... emit), crush-reweighting every OSD of one site to 0 while they stay in puts the first OSD of that site into every up set, and the other site keeps the total weight above 0. Each balancer run then aborts ceph-mgr on ceph_assert(osd_weight.count(oid)) while those PGs are active+clean. Return without changes in that case. Upmaps cannot move those PGs to an OSD with weight under the same take, and total_pgs counts the copies on the unweighted OSD, so the targets for the other OSDs would be wrong too. The mgr balancer and osdmaptool call calc_pg_upmaps() with one pool at a time, so other pools are still balanced. OSDMapTest.BUG_48896 builds such a rule with one take per datacenter, crush-reweights both OSDs of one datacenter to 0 while they stay in, checks that every PG still maps to one of them, and checks that calc_pg_upmaps() neither aborts nor upmaps a PG to a zero-weight OSD. Without the fix it aborts on the assert above. Fixes: https://tracker.ceph.com/issues/48896 Assisted-by: Claude Code
5 of 14 tasks
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.
The mgr balancer in upmap mode can abort ceph-mgr with
OSDMap.cc: FAILED ceph_assert(osd_weight.count(oid))inOSDMap::calc_deviations()(https://tracker.ceph.com/issues/48896). This happens when CRUSH maps a PG to an OSD
whose CRUSH weight is 0.
How it happens. straw2 returns the first item of a bucket when every item in it has
weight 0. The chosen leaf is then checked only against the OSD's reweight (in/out), not
its CRUSH weight. Take a rule with several
takesteps, such as the legacy stretch-moderule
take site1; chooseleaf ...; emit; take site2; chooseleaf ...; emit. If every OSDof one site is crush-reweighted to 0 while it is still in, the first OSD of that site
goes into every up set.
build_pool_pgs_info()counts the PGs on that OSD, butget_osds_weight()leaves the OSD out of the weight map. The other site keepsosd_weight_totalabove 0, so the existing early return does not fire, andcalc_deviations()asserts. With one OSD pertake, the PGs stay full size andactive+clean, so the balancer aborts the active mgr on every run. The same core shows up
now and then in
qa/standalone/mon-stretch/mon-stretch-uneven-crush-weights.sh, whichsets both OSDs of one zone to CRUSH weight 0.
When it can happen. Zero CRUSH weight alone is not enough. Adding OSDs at weight 0, or draining an OSD or a host, does not trigger it with the rules Ceph creates (
take defaultfollowed bychooseleafover hosts): straw2 never picks a zero-weight item while any sibling has weight. It also needs a manually created CRUSH rule whosetakereaches only zero-weight items. Examples are a rule with onetakeper site (as written for stretch clusters) while a whole site is crush-reweighted to 0 but still in, or, from reading straw2 but not tested, a device-class rule whose class has only zero-weight OSDs.Fix.
calc_pg_upmaps()logs an error and returns without changes when an OSD in anup set has no weight under the pool's rule. Upmaps cannot move those PGs to a weighted
OSD in the same subtree.
total_pgsalso counts the copies on the unweighted OSD, sothe targets for the rest of the pool would be wrong too. The mgr balancer and
osdmaptool --upmapcallcalc_pg_upmaps()for one pool at a time, so other pools arestill balanced.
Relation to #53736 (closed without merging). That
PR kept zero-weight OSDs in the weight map. As its author found while writing a test,
this only moves the abort to
ceph_assert(target > 0): a zero weight gives a zerotarget, and
calc_deviations()divides by the target. He also could not find how azero-weight OSD gets into an up set, so there was no reproducer. This PR leaves the
weight map and both asserts as they are. Instead it skips the pool when its mapping does
not follow its weights, and the new unit test reproduces the trigger.
One commit,
osd/OSDMap: skip calc_pg_upmaps when an up OSD has no weight, with the fix andOSDMapTest.BUG_48896. The test builds a two-datacenter rule with onetakeper datacenter, setsboth OSDs of dc-0 to CRUSH weight 0 (still in), and checks that every PG still maps to osd.0. It
then runs
calc_pg_upmaps()and checks that no PG is upmapped to a zero-weight OSD.Testing (Debug build):
unittest_osdmap --gtest_filter=OSDMapTest.BUG_48896without theOSDMap.ccchange aborts withFAILED ceph_assert(osd_weight.count(oid))incalc_deviations(). With the fix itpasses.
unittest_osdmapwith the fix: all 46 tests pass. Only the new test reaches the newearly return.
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.
🤖 Generated with Claude Code