Repository navigation
mon, crush/CrushWrapper: Create default crush rule for replicated stretch mode - #68666
Ericmzhang wants to merge 15 commits into
Conversation
342344a to
69f5c9f
Compare
|
Added tracker to commit messages. |
| local dir=$1 | ||
| shift | ||
|
|
||
| export CEPH_MON="127.0.0.1:7133" # git grep '\<7133\>' : there must be only one |
There was a problem hiding this comment.
Not unique!
qa/standalone/mon/mon-bind.sh: export MONB_PUBLIC=7133 # git grep '<7133>' ; there must be only one
| crush_rule_set_step( | ||
| rule, step++, | ||
| CRUSH_RULE_CHOOSELEAF_FIRSTN, | ||
| 2, |
There was a problem hiding this comment.
Probably want to be able to pass this value in as a parameter. Here you are creating a stretched replica pool crush rule that supports 2 copies at each site. It would be nice to be able to generalize the number of copies you have at each site rather than only supporting 2.
I suspect you'll be able to further generalize this code to support either firstn or indep so that it can generate rules for stretch EC pools as well.
There was a problem hiding this comment.
Added num_osds_per_zone cli arg to support multiple copies per site.
69f5c9f to
737107a
Compare
|
Made suggested changes from above. |
kamoltat
left a comment
There was a problem hiding this comment.
Thanks for pushing the change! I left some comments, mostly nits and maybe some unit-test additions if time permits.
| if(ret < 0) { | ||
| *err << "failed to add rule " << rno << " because " << cpp_strerror(ret); | ||
| free(rule); |
There was a problem hiding this comment.
lets guard err
if (err) {
*err << "failed to add rule " << rno << " because " << cpp_strerror(ret);
}
| "name=zone_failure_domain,type=CephString,req=false,goodchars=[A-Za-z0-9-_.] " | ||
| "name=osd_failure_domain,type=CephString,req=false,goodchars=[A-Za-z0-9-_.] " | ||
| "name=zones,type=CephInt,range=0,req=false " | ||
| "name=num_osds_per_zone,type=CephInt,range=0,req=false " |
There was a problem hiding this comment.
lets change the num_osds_per_zone to num_replica_per_zone
| for (auto child : children) { | ||
| std::vector<int> osd_failure_domains; | ||
| get_children_of_type(child, osd_type, &osd_failure_domains, false); | ||
| if (int(osd_failure_domains.size()) < num_osds_per_zone) { |
There was a problem hiding this comment.
we should change num_osds_per_zone to num_replica_per_zone
| bool force = false; | ||
| cmd_getval(cmdmap, "force", force); | ||
| string device_class; | ||
| cmd_getval(cmdmap, "class", device_class); |
There was a problem hiding this comment.
stretch mode replica doesn't support device classes just yet, we might want to support that, but that might require some re-work.
| << zone_failure_domain_name << " is less than num_failure_domains " << num_failure_domains; | ||
| return -EINVAL; | ||
| } | ||
|
|
There was a problem hiding this comment.
Lets add a check for num_failure_domains > 0 and num_replicas_per_zone > 0, we want to prevent the user from doing something silly
| .. prompt:: bash $ | ||
|
|
||
| ceph osd crush rule create-stretch-replicated [{name}] [{root}] [{zone-failure-domain}] | ||
| [{osd-failure-domain}] [{zones}] [{num_osds_per_zone] [--force] [{class}] |
| #!/usr/bin/env bash | ||
|
|
||
| source $CEPH_ROOT/qa/standalone/ceph-helpers.sh | ||
|
|
||
| function run() { | ||
| local dir=$1 | ||
| shift | ||
|
|
||
| export CEPH_MON="127.0.0.1:7159" # git grep '\<7159\>' : there must be only one | ||
| export CEPH_ARGS | ||
| CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none " | ||
| CEPH_ARGS+="--mon-host=$CEPH_MON " | ||
| # | ||
| # Disable auto-class, so we can inject device class manually below | ||
| # | ||
| CEPH_ARGS+="--osd-class-update-on-start=false " | ||
|
|
||
| local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')} | ||
| for func in $funcs ; do | ||
| setup $dir || return 1 | ||
| $func $dir || return 1 | ||
| teardown $dir || return 1 | ||
| done | ||
| } | ||
|
|
||
| function TEST_stretch_replicated() { | ||
| local dir=$1 | ||
| run_mon $dir a || return 1 | ||
| run_osd $dir 0 || return 1 | ||
| run_osd $dir 1 || return 1 | ||
| run_osd $dir 2 || return 1 | ||
| run_osd $dir 3 || return 1 | ||
|
|
||
| ceph osd crush add-bucket site1 datacenter | ||
| ceph osd crush add-bucket site2 datacenter | ||
| ceph osd crush move site1 root=default | ||
| ceph osd crush move site2 root=default | ||
| ceph osd tree | ||
| ceph osd crush rule create-stretch-replicated | ||
| ceph osd crush rule create-stretch-replicated 2>&1 | grep "Error EINVAL: zone site1 has only 0 items of type host" || return 1 | ||
|
|
||
| ceph osd crush add-bucket host1 host | ||
| ceph osd crush move host1 datacenter=site1 | ||
| ceph osd crush rule create-stretch-replicated 2>&1 | grep "Error EINVAL: zone site1 has only 1 items of type host" || return 1 | ||
|
|
||
| ceph osd crush add-bucket host2 host | ||
| ceph osd crush move host2 datacenter=site1 | ||
| ceph osd crush rule create-stretch-replicated 2>&1 | grep "Error EINVAL: host host1 has no OSDs" || return 1 | ||
|
|
||
| ceph osd crush set osd.0 1.0 host=host1 | ||
| ceph osd crush rule create-stretch-replicated 2>&1 | grep "Error EINVAL: host host2 has no OSDs" || return 1 | ||
|
|
||
| ceph osd crush set osd.1 1.0 host=host2 | ||
| ceph osd crush rule create-stretch-replicated 2>&1 | grep "Error EINVAL: zone site2 has only 0 items of type host" || return 1 | ||
|
|
||
| ceph osd crush add-bucket host3 host | ||
| ceph osd crush move host3 datacenter=site2 | ||
| ceph osd crush rule create-stretch-replicated 2>&1 | grep "Error EINVAL: zone site2 has only 1 items of type host" || return 1 | ||
|
|
||
| ceph osd crush add-bucket host4 host | ||
| ceph osd crush move host4 datacenter=site2 | ||
| ceph osd crush rule create-stretch-replicated 2>&1 | grep "Error EINVAL: host host3 has no OSDs" || return 1 | ||
|
|
||
|
|
||
| ceph osd crush set osd.2 1.0 host=host3 | ||
| ceph osd crush rule create-stretch-replicated 2>&1 | grep "Error EINVAL: host host4 has no OSDs" || return 1 | ||
|
|
||
| ceph osd crush set osd.3 1.0 host=host4 | ||
|
|
||
| ceph osd crush rule create-stretch-replicated || return 1 | ||
|
|
||
| ceph osd crush rule dump stretch_rule | jq '.steps[1].op' | grep "choose_firstn" || return 1 | ||
| ceph osd crush rule dump stretch_rule | jq '.steps[1].num' | grep "0" || return 1 | ||
| ceph osd crush rule dump stretch_rule | jq '.steps[1].type' | grep "datacenter" || return 1 | ||
|
|
||
| ceph osd crush rule dump stretch_rule | jq '.steps[2].op' | grep "chooseleaf_firstn" || return 1 | ||
| ceph osd crush rule dump stretch_rule | jq '.steps[2].num' | grep "2" || return 1 | ||
| ceph osd crush rule dump stretch_rule | jq '.steps[2].type' | grep "host" || return 1 | ||
| } | ||
|
|
||
| main crush-stretch "$@" |
There was a problem hiding this comment.
maybe name it crush-stretch-replicated, unless you are planning to add crush-stretch-ec into this as well
There was a problem hiding this comment.
Yes I was planning to add test for stretch-ec as well.
| ceph osd crush add-bucket site1 datacenter | ||
| ceph osd crush add-bucket site2 datacenter |
There was a problem hiding this comment.
lets move away from "site" and use "dc1" and "dc2" since Alex mentioned in the stretch EC document that we want to move away from site
There was a problem hiding this comment.
Thanks for creating this standalone teuthology test. One of the things I have started doing for any new stretch mode PRs is creating more unit tests, since it is cheaper and the chance of it running is 100% because it is triggered in make check. Sometimes, let’s say the teuthology rados suite runs this script—what if there is an orchestration error or just a machine error in folio or trial? Then maybe we don’t get to trigger this script. If time permits, maybe adding a unittest is also a good idea. See: https://github.com/ceph/ceph/pull/68409/changes
There was a problem hiding this comment.
Added unit test case to test/CrushWrapper.cc
737107a to
823dcaf
Compare
253563f to
10fa769
Compare
|
Made changes to review above. Added unit test to test/CrushWrapper.cc. Extracted handling in "osd crush create-replicated" and "osd crush create-stretch-replicated" to helper function crush_rule_create_replica() |
10fa769 to
1d5db48
Compare
Signed-off-by: Alex Ainscow <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
Previously bitset set did not exploit its bit-set nature by providing bitshift and other logical operators. Here we add <<, >>, <<=, >>=, &, |, &= Signed-off-by: Alex Ainscow <[email protected]>
Previously, there was no way of swapping out a transaction intended for one shard and applying it a different shard. This kind of functionality is very useful for EC stretched mode, as we often want to send the same transaction to two different shards. Due to the way transactions store a table of objects, it turns out that this is surprisingly simply process! Signed-off-by: Alex Ainscow <[email protected]>
This commit reflects an old design. We put the num_zones in the profile. Signed-off-by: Alex Ainscow <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]> # Conflicts: # src/test/osd/ECPeeringTestFixture.cc # src/test/osd/ECPeeringTestFixture.h # src/test/osd/MockPGBackendListener.h # src/test/osd/OSDMapTestHelpers.h # src/test/osd/PGBackendTestFixture.h # src/test/osd/TestECFailoverWithPeering.cc
85a5b26 to
a38c009
Compare
|
Was only adding a stretch crush rule instead of adding crush rule based on num_zones |
a38c009 to
b27cfdd
Compare
|
@Ericmzhang Think we are missing a Signed-off-by on: 637c3295e1bee02947502519daa590103d04adc1 |
| :Default: ``2`` | ||
|
|
||
| ``num_replica_per_zone`` | ||
| :Description: The expected number of osds per zone. |
There was a problem hiding this comment.
maybe: "The expected number of replica failure-domain to choose per zone"
| .. prompt:: bash $ | ||
|
|
||
| ceph osd crush rule create-stretch-replicated [{name}] [{root}] [{zone-failure-domain}] | ||
| [{osd-failure-domain}] [{zones}] [{num_replica_per_zone] [--force] [{class}] |
There was a problem hiding this comment.
| [{osd-failure-domain}] [{zones}] [{num_replica_per_zone] [--force] [{class}] | |
| [{osd-failure-domain}] [{zones}] [{num_replica_per_zone}] [--force] [{class}] |
b27cfdd to
a752d83
Compare
|
Made doc changes above |
Signed-off-by: Alex Ainscow <[email protected]>
Extended the relative shard logic to ScrubBackend::match_in_shards, and ScrubBackend::setup_ec_digest_map. When populating the digests map during shard comparison, the function now: 1. Converts absolute shard IDs to relative shards using get_rel_shard() 2. Checks if a relative shard entry already exists in the digests map 3. If it exists, compares the CRC values byte-by-byte 4. Reports a scrub error (sets digest_match = false) if CRCs don't match This ensures consistent CRC verification across zones for the same relative shard positions during the object comparison phase of scrubbing. Tested: All OSD unit tests pass (18/18) The scrubber was using absolute shard IDs when calling get_version_for_shard(), which caused false 'object info inconsistent' errors in EC pools with zone duplication. The issue occurred because get_version_for_shard() expects relative shard IDs (shard % (k+m)), not absolute shard IDs. Fixed by converting absolute shard IDs to relative shard IDs using get_ec_sinfo().get_rel_shard() for EC pools before calling get_version_for_shard(). This conversion is only needed for EC pools; replicated pools continue to use the shard ID directly. Signed-off-by: Alex Ainscow <[email protected]>
Add wrapper function add_simple_stretch_rule for default replicated stretch crush rule
rule stretch_replicated_rule {
id 2
type replicated
step take default
step choose firstn 0 type datacenter
step chooseleaf firstn 2 type host
step emit
}
Fixes: https://tracker.ceph.com/issues/76325
Signed-off-by: Eric Zhang <[email protected]>
Added "osd crush rule create-stretch-replicated" command and handling for it. Advanced flags: --zones Default Value: 2 --zone_failure_domain Default Value: datacenter --crush_root Default Value: The cluster root (default). --osd_failure_domain Default Value: host --force Default Value: false Fixes: https://tracker.ceph.com/issues/76325 Signed-off-by: Eric Zhang <[email protected]>
…e Test validation for zones >= num_failure_domain, osd_failure_domain>=2, at least one osd per host Fixes: https://tracker.ceph.com/issues/76325 Signed-off-by: Eric Zhang <[email protected]>
…replicated Fixes: https://tracker.ceph.com/issues/76325 Signed-off-by: Eric Zhang <[email protected]>
a752d83 to
02c556d
Compare
Config Diff Tool OutputThe above configuration changes are found in the PR. Please update the relevant release documentation if necessary. |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
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. |
|
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! |
Motivation: To support EC stretch mode, we need to automatically generate stretch crush rules (starting with replicated pools first)
Solution: Add a cli command to create CRUSH rules for replica pools in stretch mode.
Create a wrapper function CrushWrapper::add_simple_stretch_rule_at to create the default replica stretch rule
This wrapper function will in the future be used to also create EC stretch rules.
Fixes: https://tracker.ceph.com/issues/76325
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.