Repository navigation
osd, mon: support per-zone replica min_size for stretch pools - #35
Conversation
eaaaa32 to
297e857
Compare
822f847 to
f48487f
Compare
297e857 to
d36392d
Compare
db5e67d to
3ff0f13
Compare
4d096f1 to
abe724b
Compare
ae7e696 to
daa573c
Compare
daa573c to
920112d
Compare
88be5d1 to
fb56ba2
Compare
This commit introduces a --replica interface for both stretch pools and
non-stretch pools, replacing the absolute size approach
with per-zone replica counts for better clarity and ease of configuration.
Changes include:
1. osd pool create: Added --replica parameter to specify replicas per
zone when creating stretch pools. When set with num_zones > 0, pool
size is calculated as num_zones × replica, and min_size = num_zones.
2. mon enable_stretch_mode: Now uses mon_global_stretch_pool_replica
configuration option instead of mon_stretch_pool_size. The global
stretch mode sets size = bucket_count × mon_global_stretch_pool_replica
for all pools. The old mon_stretch_pool_size and mon_stretch_pool_min_size
options are deprecated. Disable stretch mode also make num_zones = 1
and replica = size
3. osd pool get/set: Added replica to supported pool options with
appropriate validation. Replica can only be set for replicated pools
when num_zones > 0. Changing replica automatically updates pool size.
4. Automatic size adjustment: When replica or num_zones are modified
via pool set, the pool size is automatically recalculated to maintain
size = num_zones × replica consistency.
5. Fix CRUSH rule generation to explicitly specify zone count
- Changed add_simple_stretch_rule_at() to use num_failure_domains
instead of 0 in the CHOOSE_FIRSTN step
- Ensures the rule explicitly selects from the specified number of
zones rather than relying on implicit behavior
6. Unify replica and num_replica_per_zone parameters
- Removed separate num_replica_per_zone command parameter
- Use the replica parameter value for num_replica_per_zone
- Simplifies the interface by having a single replica parameter
7. Also small fix in osd pool create --size now updates replica
as well, before this, replica was not upgraded
8. Added --replica in osd pool stretch set/unset
osd pool stretch accepts --replica and derives
num_zones using `peering_crush_bucket_barrier`
and `crush_rule`, this avoids existing users
having to update their scripts.
osd pool stretch unset also accepts replica
and works similarly to osd pool stretch,
moving the cluster back to num_zones = 1
9. Also little bug fix in enable_stretch_mode
needs to assign num_zones = 2
Conflicts (rebased onto stretchy-C, resolved as this commit intends):
src/mon/MonCommands.h: kept the order of 'mon: fix osd pool create
positional argument shift'; replica replaces num_replica_per_zone
there, and the duplicated num_zones is dropped.
src/mon/OSDMonitor.cc: this commit's prepare_pool_size(),
prepare_new_pool() and stretch set; without a num_zones argument the
default is 2 in global stretch mode, else osd_pool_default_num_zones;
try_enable_stretch_mode() keeps the degraded values for a pool
joining degraded stretch mode.
src/test/osd, src/test/osdc, src/test/mon: newer tests set num_zones
instead of the removed NUM_ZONES pool option.
doc/dev/.../ec_stretch_cluster.rst: --replica replaces
--num_replica_per_zone in sections 2.1.1 and 2.1.4, and section 2.1.3
gives the global stretch mode size from mon_global_stretch_pool_replica.
src/osd/osd_types.h: num_zones defaults to 1, as the unset NUM_ZONES
option did. Code that divides by it, such as get_zone_size() from
PGLog::rewind_divergent_log() and PeeringState::proc_master_log(), and
get_ec_data_shard_count(), raised SIGFPE for a default pg_pool_t
(unittest_pglog, unittest_peeringstate, unittest_split_ops_ut).
src/test/osd/TestECUtil.cc: get_num_zones_nonpositive is removed;
num_zones is now an unsigned field that the monitor keeps at 1 or more.
src/mon/MonCommands.h: in 'osd pool stretch set' and 'unset', replica
follows min_size, so that main's positional form, '... <crush_rule>
<size> <min_size>', keeps working. Before it, '... <crush_rule> 6 3'
took 6 as replica and failed for the missing min_size.
src/mon/OSDMonitor.cc: 'osd pool create' takes the zone failure domain
from --zone_failure_domain, else in global stretch mode from the stretch
mode's dividing bucket type, else from default_crush_zone_failure_domain
later on. A fixed "datacenter" made every create in a global stretch
mode divided by another type fail with "CRUSH rule <n> is stretched
across datacenter instead of <type>", now that its pools have
num_zones 2.
src/mon/OSDMonitor.cc: 'osd pool set' stores a pool option after its
checks again, for every option but num_zones and replica, which are
pool fields now. As one more branch of the chain of checks, the store
was skipped for every option that has a check, such as
recovery_priority, pg_num_min and compression_mode: the command
reported the option as set and left the pool unchanged.
qa/standalone/crush/crush-stretch.sh: the stretch rules now choose
num_zones zones ('choose firstn 2') instead of 'choose firstn 0', as
this commit's change to add_simple_stretch_rule_at() makes them.
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
This change extends 'osd pool set num_zones' to support transitioning
existing pools between single-zone and multi-zone (stretch) configurations,
similar to how 'osd pool create' already supports stretching a pool.
1. Stretching pools (num_zones: 1 → 2+):
- Requires --zone_failure_domain for all pool types
- Replicated pools: requires --replica and --osd_failure_domain
- EC pools: uses existing erasure_code_profile, validates FastEC support
- Creates/assigns appropriate CRUSH rule via prepare_pool_crush_rule()
- Sets peering parameters (barrier, count, target) based on zone topology
- For num_zones=2: enables monitor and pool-level stretch mode
- Automatically calculates pool size (legacy support):
* Replicated: size = num_zones * replica
* EC: size = num_zones * (k+m)
2. Unstretching pools (num_zones: 2+ → 1):
- Clears all stretch-related pool parameters (peering_crush_bucket_*)
- Resets pool size/min_size to osd_pool_default values
- Resets replica = size (since num_zones = 1)
- When last pool is unstretched: clears OSDMap and MonMap stretch
mode state via clear_stretch_mode_state()
3. Enhanced 'osd pool set replica':
- Now automatically recalculates pool size when replica changes
- Formula: size = num_zones * replica
- Validates new size with pg_num before applying
- Provides informative output showing zone/replica breakdown
Replicated pools:
- size = osd_pool_default_size (typically 3)
- min_size = osd_pool_default_min_size(size)
- replica = size (since num_zones = 1)
EC pools:
- size = k + m (from erasure_code_profile)
- min_size = k + min(1, m-1) (standard EC formula)
- replica field not modified (EC pools don't use it)
Conflicts (rebased onto stretchy-C):
src/mon/OSDMonitor.cc: removed the pool size adjustments after
'osd pool set', as this commit does. Calls the current
enable_pool_ec_optimizations(), which returns tl::expected.
src/mon/OSDMonitor.h: declares maybe_remove_unused_crush_rule(), which
this commit defines; it was declared only in a later commit.
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Include the requested replica count per zone in the error emitted when a zone does not contain enough failure-domain items. This makes it clear why the requested stretch pool or CRUSH rule cannot be created and how many hosts are required. Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Add osd_pool_stretch_default_replica to configure the default number
of replicas per zone when creating a multi-zone replicated pool.
Previously, `osd pool create <pool> --num_zones <n>` without
`--replica` used osd_pool_default_size as the total size, then derived
replica by integer division. With the default size of 3 and two zones,
this produced size 3 and replica 1 despite the generated CRUSH rule
requiring two replicas per zone.
Default the per-zone replica count from the new configuration option,
then calculate the pool size as num_zones * replica.
Conflicts (rebased onto stretchy-C):
doc/dev/.../ec_stretch_cluster.rst, qa/standalone/crush/crush-stretch.sh:
the size of a replicated multi-zone pool comes from --replica and
osd_pool_stretch_default_replica.
src/mon/OSDMonitor.cc: the default replica applies to replicated pools
only. Applied to an erasure coded pool, it made every create with
num_zones > 1 fail with "replica is only applicable to replicated
pools".
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
1. Make min_size become per-zone for default stretch pool
When creating a replicated pool with num_zones > 1 and --replica is
specified but --min_size is not, derive min_size from the per-zone
replica count with get_osd_pool_default_min_size().
This keeps replica, size, and min_size consistent for stretch pools,
where replica and min_size are interpreted per zone.
2. Generalize stretch_num_acting_below_min_size() so it evaluates both
erasure-coded and replicated stretch pools.
Use the generalized per-zone minimum-size check when determining
whether a PG can become active, prioritizing recovery and backfill,
selecting async recovery targets, priming pg_temp mappings, and
checking whether OSDs are safe to stop. This prevents replicated
stretch pools from remaining writeable when their total acting set
meets min_size but an individual zone does not.
3. Support per zone min_size upgrade path and make 3AZ cluster an
exception.
Upgraded clusters that are stretched will now use per zone min_size.
3AZ cluster will evaluate min_size as a whole cluster rather per zone
since we don't support degraded stretch mode in 3AZ yet.
Conflicts (rebased onto stretchy-C):
src/mon/MonCommands.h: min_size follows the stretch parameters, in the
order of 'mon: fix osd pool create positional argument shift'.
src/mon/OSDMonitor.cc: as this commit does.
src/osd/OSDMap.cc: this commit's stretch_num_acting_below_min_size(),
finding the zones with get_stretch_zones() and comparing the
mandatory member by non-shadow id, as stretchy-C now does.
src/osd/PeeringState.cc: choose_async_recovery_ec() uses this
commit's per-zone check for stretch pools, but keeps
'want_acting_size > min_size' for other EC pools. recoverable()
checks min_size only when osd_allow_recovery_below_min_size is
false, which is not the default.
src/test/osd/TestStretchECMinSize.cc: newer tests call
stretch_num_acting_below_min_size().
src/mon/OSDMonitor.cc: a pool created in degraded global stretch mode
no longer has its min_size halved, since the transitions no longer
restore it.
qa/standalone/crush/crush-stretch.sh: a 2-zone pool with 2 replicas per
zone has the per-zone default min_size, 1.
doc/dev/.../ec_stretch_cluster.rst: section 11.4.3 no longer halves the
min_size of a pool created in degraded stretch mode.
src/test/osd/TestStretchECMinSize.cc: NumActingBelowMinSize_ReplicatedPool
expects a replicated stretch pool to be counted per zone, as this
commit does.
src/mon/OSDMonitor.cc: a pool created in degraded global stretch mode
gets the surviving zone as mandatory member, as the other stretch pools
have. Without it, the per-zone min_size counted the lost zone too, and
the new pool's PGs could not go active until the zone returned.
Section 11.4.3 of the design says so.
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
- Added TEST(ECPoolCreatePP, ReplicatedPoolSetNumZones)
- Added TEST(ECPoolCreatePP, ErasurePoolSetNumZones)
- Added OSDMonitor::maybe_remove_unused_crush_rule
Conflicts (rebased onto stretchy-C):
src/mon/OSDMonitor.h: maybe_remove_unused_crush_rule() is now declared
by "mon: support entering/exiting per pool stretch-mode via
num_zones", which defines it.
Signed-off-by: Callum James <[email protected]>
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Conflicts (rebased onto stretchy-C):
doc/rados/operations/stretch-mode.rst: num_zones=N replaces zone=N as
in this commit; existing pools enter per-pool stretch mode with
'ceph osd pool set <pool> num_zones <N>', as "mon: support
entering/exiting per pool stretch-mode via num_zones" implements.
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Restore single-zone sizing, peering settings and CRUSH rules when unstretching pools. Reject unsupported zone counts and overflowing sizes, preserve rules on no-op commands, and account for pending pool references during rule cleanup. Use named EC transition rules and honor failure-domain parameters. Coordinate MonMap and OSDMap transitions in a shared immediate Paxos proposal to prevent election loops before the pool update commits. Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Create and assign a rule named <pool>-replica-<count> when changing the per-zone replica count. Continue updating the pool when the named rule already exists, validate field bounds, and recalculate size and min_size consistently with multi-zone pool creation. Preserve the current rule's root and failure domains, remove unreferenced replaced rules Document the replica and minimum-size behavior. Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Add a standalone three MONs, six OSDs regression covering replica-specific rule naming and reuse, size/min_size expectations, invalid inputs, no-op commands, and replicated and erasure-coded stretch/unstretch transitions. Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
… pool Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main, without its erasure coded test: stretchy-C follows #35, in which 'ceph osd pool stretch set' accepts an erasure coded pool. Drop when stretchy-C is rebased onto a main that has it, keeping that difference. Add mon-stretch-commands.sh for the stretch pool and stretch mode commands, with a test on 3 mons and no OSDs that stretches a replicated pool with 'ceph osd pool stretch set' and returns it with 'unset'. Assisted-by: Claude Code Signed-off-by: Alex Ainscow <[email protected]>
6269799 to
9d42537
Compare
|
Rebased onto the rewritten stretchy-C (42e56af) and force-pushed with lease. All 11 commits are yours; where the rebase changed one, its message has a
Open: Testing: full build; unit tests (osd_monitor, mon_monmap, osdmap, EC backend and peering, pglog, scrub, crush, stretch min_size); standalone: every mon-stretch script including |
6583a08 ("mon: Prevent osd pool stretch set for EC", #41) made ceph osd pool stretch set refuse EC pools: an EC pool is stretched and unstretched with ceph osd pool set <pool> num_zones <n>, which works out the rule, size, min_size, peering values and nonprimary_shards from the zone count. 8b30768 ("mon: add per-zone replica configuration for stretch pools", #35), written before that change and merged after it, brought back the older EC branch. stretch set has accepted a FastEC pool again since, while doc/rados/operations/pools.rst still says it is for replicated pools only. stretch set now refuses every EC pool again, with the message of 6583a08. stretch unset refuses an EC pool with num_zones > 1 and points to num_zones 1. It accepts an EC pool with one zone only with size k+m and min_size from k to k+m, as main does (ceph#72416), because only an older release's stretch set could have stretched such a pool. That check is OSDMonitor::check_stretch_unset_ec(), which has unit tests. The design (Sections 2.1.5 and 11.4.1) now states this and why, and pools.rst says what stretch unset does with an EC pool. stretch set no longer needs its own refusal of EC pools before the upgrade commit, and the nonprimary_shards updates in stretch set and unset go, because no multi-zone EC pool reaches them. Tests: TEST_stretch_set_ec_pool in mon-stretch-commands.sh, and the pre-commit stretch set check in mon-stretch-upgrade.sh expects the new message. Assisted-by: Claude Code
6583a08 ("mon: Prevent osd pool stretch set for EC", #41) made ceph osd pool stretch set refuse EC pools: an EC pool is stretched and unstretched with ceph osd pool set <pool> num_zones <n>, which works out the rule, size, min_size, peering values and nonprimary_shards from the zone count. 8b30768 ("mon: add per-zone replica configuration for stretch pools", #35), written before that change and merged after it, brought back the older EC branch. stretch set has accepted a FastEC pool again since, while doc/rados/operations/pools.rst still says it is for replicated pools only. stretch set now refuses every EC pool again, with the message of 6583a08. stretch unset refuses an EC pool with num_zones > 1 and points to num_zones 1. It accepts an EC pool with one zone only with size k+m and min_size from k to k+m, as main does (ceph#72416), because only an older release's stretch set could have stretched such a pool. That check is OSDMonitor::check_stretch_unset_ec(), which has unit tests. The design (Sections 2.1.5 and 11.4.1) now states this and why, and pools.rst says what stretch unset does with an EC pool. stretch set no longer needs its own refusal of EC pools before the upgrade commit, and the nonprimary_shards updates in stretch set and unset go, because no multi-zone EC pool reaches them. Tests: TEST_stretch_set_ec_pool in mon-stretch-commands.sh, and the pre-commit stretch set check in mon-stretch-upgrade.sh expects the new message. Assisted-by: Claude Code
6583a08 ("mon: Prevent osd pool stretch set for EC", #41) made ceph osd pool stretch set refuse EC pools: an EC pool is stretched and unstretched with ceph osd pool set <pool> num_zones <n>, which works out the rule, size, min_size, peering values and nonprimary_shards from the zone count. 8b30768 ("mon: add per-zone replica configuration for stretch pools", #35), written before that change and merged after it, brought back the older EC branch. stretch set has accepted a FastEC pool again since, while doc/rados/operations/pools.rst still says it is for replicated pools only. stretch set now refuses every EC pool again, with the message of 6583a08. stretch unset refuses an EC pool with num_zones > 1 and points to num_zones 1. It accepts an EC pool with one zone only with size k+m and min_size from k to k+m, as main does (ceph#72416), because only an older release's stretch set could have stretched such a pool. That check is OSDMonitor::check_stretch_unset_ec(), which has unit tests. The design (Sections 2.1.5 and 11.4.1) now states this and why, and pools.rst says what stretch unset does with an EC pool. stretch set no longer needs its own refusal of EC pools before the upgrade commit, and the nonprimary_shards updates in stretch set and unset go, because no multi-zone EC pool reaches them. Tests: TEST_stretch_set_ec_pool in mon-stretch-commands.sh, and the pre-commit stretch set check in mon-stretch-upgrade.sh expects the new message. Assisted-by: Claude Code
…replicated pool Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main, without its erasure coded test: stretchy-C follows #35, in which 'ceph osd pool stretch set' accepts an erasure coded pool. Drop when stretchy-C is rebased onto a main that has it, keeping that difference. Add mon-stretch-commands.sh for the stretch pool and stretch mode commands, with a test on 3 mons and no OSDs that stretches a replicated pool with 'ceph osd pool stretch set' and returns it with 'unset'. Assisted-by: Claude Code Signed-off-by: Alex Ainscow <[email protected]> (cherry picked from commit 9b7688f)
…replicated pool Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main, without its erasure coded test: stretchy-C follows #35, in which 'ceph osd pool stretch set' accepts an erasure coded pool. Drop when stretchy-C is rebased onto a main that has it, keeping that difference. Add mon-stretch-commands.sh for the stretch pool and stretch mode commands, with a test on 3 mons and no OSDs that stretches a replicated pool with 'ceph osd pool stretch set' and returns it with 'unset'. Assisted-by: Claude Code Signed-off-by: Alex Ainscow <[email protected]> (cherry picked from commit 9b7688f)
…replicated pool Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main, without its erasure coded test: stretchy-C follows #35, in which 'ceph osd pool stretch set' accepts an erasure coded pool. Drop when stretchy-C is rebased onto a main that has it, keeping that difference. Add mon-stretch-commands.sh for the stretch pool and stretch mode commands, with a test on 3 mons and no OSDs that stretches a replicated pool with 'ceph osd pool stretch set' and returns it with 'unset'. Assisted-by: Claude Code Signed-off-by: Alex Ainscow <[email protected]> (cherry picked from commit 9b7688f)
…plicated pool Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main, without its erasure coded test: stretchy-C follows #35, in which 'ceph osd pool stretch set' accepts an erasure coded pool. Drop when stretchy-C is rebased onto a main that has it, keeping that difference. Add mon-stretch-commands.sh for the stretch pool and stretch mode commands, with a test on 3 mons and no OSDs that stretches a replicated pool with 'ceph osd pool stretch set' and returns it with 'unset'. Assisted-by: Claude Code Signed-off-by: Alex Ainscow <[email protected]> (cherry picked from commit 9b7688f)
…plicated pool Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main, without its erasure coded test: stretchy-C follows #35, in which 'ceph osd pool stretch set' accepts an erasure coded pool. Drop when stretchy-C is rebased onto a main that has it, keeping that difference. Add mon-stretch-commands.sh for the stretch pool and stretch mode commands, with a test on 3 mons and no OSDs that stretches a replicated pool with 'ceph osd pool stretch set' and returns it with 'unset'. Assisted-by: Claude Code Signed-off-by: Alex Ainscow <[email protected]>
Summary
Add per-zone replica and min_size semantics for stretch replicated pools.
This enables configuring the replica count used in a stretch pool's CRUSH
rule and derives the pool size and min_size from the number of zones and
replicas per zone. It also supports converting pools into and out of stretch
mode through
osd pool set num_zones.Details
--replicasupport to stretch pool create, set, and unset commandsnum_zonesandreplicastop-safety decisions
clusters, where degraded stretch mode is unsupported
Testing
TestStretchECMinSizeNotes
This series touches pool mutation, CRUSH-rule generation, stretch-mode
transitions, and peering behavior. Upgrade and existing-pool conversion paths
should receive integration coverage.
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.