Skip to content

crush/CrushWrapper: fix verify_upmap for nested choose rules - #69151

Closed
LeonGao91 wants to merge 2 commits into
ceph:mainfrom
LeonGao91:fix-verify-upmap-nested-choose
Closed

LeonGao91 wants to merge 2 commits into
ceph:mainfrom
LeonGao91:fix-verify-upmap-nested-choose

Conversation

@LeonGao91

@LeonGao91 LeonGao91 commented May 28, 2026 •

Copy link
Copy Markdown

Summary

verify_upmap() checks each choose step's numrep against the count of distinct parents in the candidate up set, but ignores that an inner choose step's numrep is per outer-bucket-result. For multi-level rules (e.g. choose pod -> choose rack -> chooseleaf osd) a legitimate up set spans numrep * outer_numrep_product distinct buckets, so valid upmaps are rejected and silently removed by check_pg_upmaps in the next osdmap epoch.

This fix tracks a running product of numrep across prior choose/chooseleaf steps in the current TAKE..EMIT scope and compares each inner step against numrep * outer_numrep_product. Single-level rules are unaffected (the product is 1 for the first step after TAKE).

Issue tracker: https://tracker.ceph.com/issues/51729

Test plan

  • unittest_crush_wrapper -- new verify_upmap_nested_choose (asserts previously-rejected nested-choose up sets now validate, and genuinely invalid sets still fail) and verify_upmap_single_level regression guard.
  • Patch was deployed against an EC 6+4 pool with a pod -> rack -> osd rule; pg-upmap-items entries persist across osdmap epochs (pre-fix they were silently removed).

@LeonGao91
LeonGao91 requested a review from a team as a code owner May 28, 2026 22:27
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

16 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

LeonGao91 added 2 commits May 28, 2026 16:06
verify_upmap() walks each step of a CRUSH rule and, for each
choose_firstn/choose_indep step at a non-leaf type, asserts that
the number of distinct parents of that type in the candidate up
set does not exceed the step's numrep. This is correct for a
single-level rule, but it ignores the fact that an inner choose
step's numrep is per outer-bucket-result.

For an EC 6+4 pool with the rule

  take <root>
  choose_indep 5 type pod
  choose_indep 2 type rack
  chooseleaf_indep 1 type osd
  emit

a valid up set legitimately contains 10 distinct racks (2 per
pod * 5 pods). The current check evaluates 10 > 2 and returns
-EINVAL, so any pg-upmap-items the operator sets is silently
removed by check_pg_upmaps in the next osdmap epoch.

Track a running product of numrep across prior choose/chooseleaf
steps in the current TAKE..EMIT scope. Compare each inner choose
step's parents_of_type count against numrep * outer_numrep_product
instead of numrep alone. Reset the product on TAKE and EMIT so
multi-rule scripts behave correctly.

Single-level rules behave identically: outer_numrep_product is 1
for the first choose step after TAKE.

Builds on prior unmerged patches in tracker ceph#51729 (Laura Flores's
wip-tracker-51729 branch, comment ceph#22, and Andras Pataki's revision
in comment ceph#24). This revision keeps the running product separate
from type_stack to preserve per-level numrep semantics, resets it
across multiple TAKE..EMIT scopes, and is paired with unit-test
coverage in a follow-up commit.

Fixes: https://tracker.ceph.com/issues/51729
Suggested-by: Laura Flores <[email protected]>
Suggested-by: Andras Pataki <[email protected]>
Signed-off-by: Leon Gao <[email protected]>
Add two unit tests to cover the verify_upmap fix:

* verify_upmap_nested_choose -- builds a multi-level CRUSH rule
  (choose pod, choose rack, chooseleaf osd) shaped like the
  multi-level EC rules reported in tracker ceph#51729 (e.g. the
  rack/chassis/host rule in note ceph#9, the pod/rack/osd rule in
  note ceph#24). Asserts natural CRUSH outputs and same-rack upmap
  targets validate, while genuinely invalid up sets (spanning
  more pods than numrep allows) are still rejected.

* verify_upmap_single_level -- regression guard for plain
  single-level chooseleaf rules; ensures the new
  outer_numrep_product accounting does not change behavior
  for the common single-step case.

The first test fails on the unfixed verify_upmap because the
inner choose-rack step counts 4 distinct racks against
numrep=2 and returns -EINVAL.

Related: https://tracker.ceph.com/issues/51729
Signed-off-by: Leon Gao <[email protected]>
@LeonGao91
LeonGao91 force-pushed the fix-verify-upmap-nested-choose branch from 4b05800 to 9b929e5 Compare May 28, 2026 23:08
@rzarzynski
rzarzynski requested a review from ljflores June 1, 2026 19:04
@LeonGao91

Copy link
Copy Markdown
Author

@ljflores Gentle ping in case this slipped away, thanks!

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@next0262

next0262 commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

I came at verify_upmap from a different angle (multi-take rules, #71053) and read through this one. I applied it on top of current main and ran the suite: your two tests pass, along with the rest of unittest_crush_wrapper (26/26) and unittest_osdmap (41/41).

The approach looks right to me — the inner step's numrep is per outer result, so comparing the total against numrep alone is wrong.

Two small things:

Since it touches the same lines: the checks still run against the whole up vector, which breaks separately for rules with more than one take step. That is what #71053 fixes. The two look independent — I ran both reproducers each way — but one will need a rebase on the other, and I am happy to go in whichever order suits you.

@github-actions github-actions Bot removed the stale label Aug 14, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Oct 13, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions github-actions Bot closed this Nov 12, 2026
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.

3 participants