Skip to content

mon: preserve EC profile failure domain - #61

Closed
kamoltat wants to merge 173 commits into
mainfrom
stretchy-C
Closed

kamoltat wants to merge 173 commits into
mainfrom
stretchy-C

Conversation

@kamoltat

@kamoltat kamoltat commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Problem:
commits (8b30768: mon: add per-zone replica configuration for stretch pools) added this line into the osd pool create path

osd_failure_domain = cmd_getval_or<string>(cmdmap, "osd_failure_domain", "host");

In a scenario where the user provides their own ec profile when creating a stretch pool, this was overwriting the osd_failure_domain from that profile with 'host' which was causing some issues for setting up teuthology tests which set up a crush config expecting osd_failure_domain = osd.

Solution:
use cmd_getval and in replicated pool type do

osd_failure_domain = cmd_getval_or<string>(cmdmap, "osd_failure_domain", "host");

Signed-off-by: Kamoltat (Junior) Sirivadhna [email protected]

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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

aainscow and others added 30 commits October 2, 2026 15:53
Only the ec_impl constructor and the plain (k, m, stripe_width) test
constructor initialised the const all_shards member. The (k, m,
stripe_width, chunk_mapping), (k, m, stripe_width, pool) and (k, m,
stripe_width, pool, chunk_mapping) constructors left it empty, so
get_all_shards() returned an empty set and any loop over it was silently
skipped in the unit tests built on them (for example the scrub backend
tests, whose TestPg uses the pool constructor).

Initialise it with calc_all_shards(k + m) as the other constructors do.
These constructors are only used by unit tests; the production (ec_impl)
constructor is unchanged, so this is a test-only defect with no effect
on the OSD.

Tested by ECUtil.get_all_shards_every_constructor in the following
commit. unittest_ecutil, unittest_ecbackend, unittest_extent_cache and
unittest_ec_transaction all pass.

Fixes: https://tracker.ceph.com/issues/81296
Assisted-by: Claude Code
Tests "osd/ECUtil: initialise all_shards in every stripe_info_t
constructor".

ECUtil.get_all_shards_every_constructor builds a k=2, m=1 stripe_info_t
with each of the test constructors ((k, m, stripe_width), (k, m,
stripe_width, chunk_mapping), (k, m, stripe_width, pool) and (k, m,
stripe_width, pool, chunk_mapping)) and checks that get_all_shards()
returns shards 0..2. Without the fix the last three return an empty set,
so code that iterates get_all_shards() silently does nothing under test
harnesses such as unittest_scrubber_be, whose TestPg builds its
stripe_info_t with the (k, m, stripe_width, pool) constructor.

Assisted-by: Claude Code
Add wrapper function add_simple_stretch_rule for default 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
}

and

rule stretch_ec_rule {
        id 2
        type erasure
        step set_chooseleaf_tries 5
        step set_choose_tries 100
	step take default
        step choose firstn 0 type datacenter
        step chooseleaf indep 6 type host
        step emit
}

Fixes: https://tracker.ceph.com/issues/76325

Signed-off-by: Eric Zhang <[email protected]>
create_rule() could only build a rule from values embedded in the
erasure-code profile, so a stretch EC pool had to have its zone count,
CRUSH root and failure domains fixed when the profile was created.

Give create_rule() explicit num_zones, root, zone_failure_domain,
osd_failure_domain and device_class parameters and, when more than one
zone is asked for, build the rule through
CrushWrapper::add_simple_stretch_rule().  A value passed in takes
precedence over the same value in the profile, so a caller can create a
stretch rule without first defining a bespoke profile; the profile still
supplies the default whenever a parameter is left empty.

The original three-argument create_rule() is kept as a non-pure virtual
that delegates with a single zone and empty overrides, so existing
callers and out-of-tree plugins continue to compile and behave as before.

The stretch parameters are also plumbed through the OSD JSON structures,
and the erasure-code tests and the OSD erasure-code mock are updated for
the widened interface.

Signed-off-by: Eric Zhang <[email protected]>
Assisted-by: Claude Opus 5 (1M context) <[email protected]>
…est doubles

ErasureCodeExample and MockErasureCode override one create_rule()
overload and inherit the other, which -Woverloaded-virtual reports as the
derived declaration hiding the base one.

Bring the base overloads back into scope with a using declaration so the
test builds stay quiet.

Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Assisted-by: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
Assisted-by: IBM Bob v2.1.0
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]>

# Conflicts:
#	src/mon/OSDMonitor.cc
Added  "osd crush rule create-stretch-replicated" command and handling for it.
Advanced flags:
--zones Default Value: 2
--zone_failure_domain Default Value: datacenter
--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]>
… coded stretch mode

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]>
Get rid of ec pool restrictions, allowing user to enter
stretch mode with EC pool.

Refactor OSDMonitor::try_enable_stretch_mode_pools() to extract
validation logic into static validate_stretch_mode_pools() function,
making it testable without requiring a full OSDMonitor instance.

Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Add unittest_osd_monitor.cc with 11 test cases validating pool
configuration requirements for entering stretch mode:
- Replicated pools must have default size/min_size
- Pool type must match CRUSH rule type (replicated vs ec)
- CRUSH rule must exist
- All pools in a set must pass validation

Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Call helper functions crush_rule_create_replica() and crush_rule_create_erasure()
which generate crush rules. Add args to osd pool create cli for creating crush rule

Fixes: https://tracker.ceph.com/issues/76325

Signed-off-by: Eric Zhang <[email protected]>
…ool create

Test stretch crush rule generation tests for osd pool create for both EC and replica

Fixes: https://tracker.ceph.com/issues/76325

Signed-off-by: Eric Zhang <[email protected]>
Automatically enter connectivity mode when executing
`ceph osd pool create` with > 1 zones.

create a static helper function ensure_connectivity_strategy
such that is unittestable in `test_monmap_monitor.cc`

Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
-Added validation that new pools in stretch mode have CRUSH rules that stretch across the same sites.
-Allow mixing of stretch pools  with different device classes and CRUSH rules

Signed-off-by: Eric Zhang <[email protected]>
Introduces three new optional parameters to 'osd pool create' command (k, m, num_zones) that enable automatic EC profile creation alongside pool creation.

The num_zones parameter is moved from the EC profile level to the pool level.

Signed-off-by: Callum James <[email protected]>
Introduce per-pool stretch mode alongside global stretch mode, allowing
users to enable stretch mode selectively for individual pools or globally
across the entire cluster.

Per-pool stretch mode:
- Enabled via `ceph osd pool create <name> zone=2`
- Only affects the specified pool
- Existing pools and future pools remain unaffected

Global stretch mode:
- Enabled via `ceph mon enable_stretch_mode`
- Applies to all existing pools and any pools created in the future
- Provides cluster-wide stretch mode protection

Add global_stretch_mode_enabled field to MonMap to distinguish between
global stretch mode and per-pool stretch mode configurations. Pools
operating in per-pool stretch mode (without global_stretch_mode_enabled)
retain full stretch mode functionality including peering_crush_bucket
settings and the ability to enter degraded_stretch_mode and
recovering_stretch_mode states.

osd pool rm <pool-name> on the last per pool stretch mode will
clear any stretch mode flags and related attributes in both
monmap and osdmap.

Upgrade handling:
- MonMap v9 → v10: When decoding old MonMaps, automatically set
  global_stretch_mode_enabled = stretch_mode_enabled, which is enough to
  carry an existing stretch cluster over; it deliberately does not run on
  every pending monmap
- Ensures existing stretch mode clusters seamlessly transition to the
  new global stretch mode model upon upgrade

Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Assisted-by: Claude Opus 5 (1M context) <[email protected]>
Update the unit-test, also added a code path
that checks exercises global_stretch_mode_enabled field
in MonmapMonitor::validate_and_enable_stretch_mode

Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Update stretch_mode_disable_enable.py to validate the new
global_stretch_mode_enabled field in MonMap when enabling and disabling
stretch mode.

- Add assertion in _stretch_mode_enabled_correctly() to verify
  monmap['global_stretch_mode'] is True
- Add assertion in _stretch_mode_disabled_correctly() to verify
  monmap['global_stretch_mode'] is False

This ensures the QA tests validate that the global_stretch_mode_enabled
flag is properly set/cleared when using the mon enable_stretch_mode and
mon disable_stretch_mode commands.

Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Update the docs to reflect the code changes

Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
…g CRUSH rules

-Tests for allowing mixed device classess and different CRUSH rules
-Test validation preventing adding new pools in stretch mode with CRUSH rules across different sites

Signed-off-by: Eric Zhang <[email protected]>
Add tests for osd stretch set validating different CRUSH rules and changing size for EC pools

Signed-off-by: Eric Zhang <[email protected]>
…rtly

Created calc_ec_acting_stretch which is similar
to calc_replicated_acting_stretch in that we police
the OSDs we are adding to the acting set by making
sure it doesn't go beyond the `bucket_max` we set for each
zone in stretch ec cluster.

What differ is that calc_ec_acting_stretch is zone aware
when choosing an osd, we check whether the shard matches
the osd in terms of zone.

As for choose_async_recovery_ec
we make sure that we have enough OSDs from each zones before
taking it out for async_recovery.

For pg_pool_t::stretch_set_can_peer ignore
OSDs == CRUSH_ITEM_NONE since this can happen
with EC pools.

Initialized TestECActingStretch  to test both calc_ec_acting_stretch
and choose_async_recovery_ec.

Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
update MonCommands.h removing `zones`
update the docs for ec_stretch_cluster to not include `zones`
update the tests to not use `zones` but to use `num_zones`

Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
Modify min_size changes when entering degraded and healthy states
to be per-zone.

Created stretch_ec_num_acting_below_min_size which checks if any zone
does not meet min_size for stretch ec pools

Modify checks of if(acting.size() < min_size) to also call
stretch_ec_num_acting_below_min_size if needed

Change recovery and backfilling priorities to use
stretch_ec_num_acting_below_min_size if stretch ec pool

Signed-off-by: Eric Zhang <[email protected]>
…SDMap::stretch_ec_num_acting_below_min_size

Unit tests for per zone min-size

Signed-off-by: Eric Zhang <[email protected]>
Split reads and single-chunk EC direct reads pin each read to one shard
OSD with CEPH_OSD_FLAG_FORCE_OSD. _calc_target() only reacts to an
acting-set change that leaves the primary alone if used_replica is set,
and ignores a new interval that leaves the acting set alone, such as a
min_size change. A non-primary OSD drops direct reads sent in an earlier
interval, so such a read was neither resent nor failed back, and hung.

Check forced-OSD targets for a new interval in _calc_target() as if
any_change were set, so that every new interval of their PG reaches the
forced-OSD check and the read falls back to the primary. Targets whose PG
interval is unchanged are still left alone.

Makes TestSplitOpMapChange.ECSplitReadRedrivesWhenMinSizeChanges and
ECDirectReadRedrivesWhenMinSizeChanges from "test/osd: demonstrate EC
direct reads not failed back on a new interval" pass.

Fixes: https://tracker.ceph.com/issues/81194
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit ddc2a23)
ECSplitReadShardsMoveDuringSubmit sets objecter_debug_inject_relock_delay
so that a map moving every shard of the PG lands while _op_submit() has
dropped the rwlock for the first sub-read of a balanced EC split read.

The first sub-read's target is recalculated after the relock, its PG has
changed, and it is parked in the homeless session with a map check
registered. The second sub-read copies the parent's target from before
the map and, as an EC direct read, skips _calc_target() in _op_submit(),
so it is sent to its old OSD with its old shard.

The next map that changes the PG completes the parked sub-read with
-EAGAIN through _check_op_pool_dne(), which calls _finish_op() while the
op is still in check_latest_map_ops, and the client aborts.

advance_map() now wants the next OSDMap from the MonClient before
delivering each map, so that an op left without an OSD does not make the
unconnected MonClient try to open a session.

Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit e04146d)
If _op_submit() relocks, a map lands and the recalculated target gives
RECALC_OP_TARGET_POOL_DNE, the op is parked in the homeless session and
registered in check_latest_map_ops until the monitor reports the latest
OSDMap. If another map changes the PG first, _scan_requests() gets
POOL_DNE again and calls _check_op_pool_dne(). For a pool that existed,
that completes the op and calls _finish_op() at once, which asserts that
the op is not in check_latest_map_ops.

A split sub-read whose PG has changed gets POOL_DNE on purpose, so that
it fails with -EAGAIN, which makes this easy to reach. A pool deleted
during the relock reaches it too.

Cancel any map check before finishing the op. When the monitor's reply
calls _check_op_pool_dne(), the entry has already been removed and the
cancel does nothing.

With this, TestSplitOpMapChange.ECSplitReadShardsMoveDuringSubmit from
"test/osd: demonstrate split sub-reads racing a map during submit" no
longer aborts.

Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit 3b5c2b2)
_op_submit() skips _calc_target() for CEPH_OSD_FLAG_EC_DIRECT_READ ops
because SplitOp has just calculated their targets. A split read copies
the parent's target into each sub-read, so if _op_submit() relocks for
one sub-read and a map lands, the later sub-reads keep a target from the
older map and are sent to the OSD that held their shard in it, which may
have moved or gone down. Nothing corrects this until the next map changes
the PG.

Recalculate a direct read's target in _op_submit() when it was
calculated with an older map. A target whose PG is unchanged is kept,
and a sub-read whose PG has changed is parked until the monitor's
reply or the next map fails it with -EAGAIN, so the parent is retried at
the primary.

Makes TestSplitOpMapChange.ECSplitReadShardsMoveDuringSubmit from
"test/osd: demonstrate split sub-reads racing a map during submit"
pass.

Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit d96ba9f)
Trimming the log so that the up OSDs of a remap need backfill, applying
a pg-upmap and a pg_temp, and faking a backfill target's progress and
completion become TestECStretchPeering helpers. The two zone block swap
tests use them, and the tests that follow repeat these steps.

Assisted-by: Claude Code
A pg-upmap moves a stretch EC PG's zone blocks to the other datacenters
while a pg_temp keeps the acting set on the pre-upmap up set. A zone
failure, then one more OSD failure, can leave only the k up shards of
one block, and those take every write. When the zone returns,
calc_ec_acting_stretch() serves the blocks from the datacenters of the
pre-upmap up set again, which hold more usable shards while the other
block's up shards are still being backfilled. The up shards holding the
newest writes become backfill targets, because their datacenter is the
goal for their block, and activate() restarts them from last_backfill
MIN. Recovery does not use a backfill target's objects, so the writes
held only there become unfound and backfill cannot start. Two
fault-injection runs on a test cluster ended this way, with 79 and 9
objects unfound and every OSD up.

TestECStretchPeering.ReturningZone_NewestWritesNotUnfound drives the
peering state machines through the whole sequence: the pg-upmap with the
pg_temp, the zone failure and the backfill of the surviving zone's up
shards, one more OSD down so the k remaining up shards of one block take
every write, the pg-upmap removed while the PG writes on without those
shards, and the pg-upmap back with the whole zone. It expects the
writes to stay recoverable.

Two TestECActingStretch tests check calc_ec_acting_stretch() decisions
from the run that left 9 writes of PG 2.39 unfound, with the run's OSD
ids mapped onto the fixture:

- ReturningEmptyUpShard_KeepsUpActingZones, epoch 6256: up = acting
  with block 0 in dc0 after a pg-upmap, and one up OSD returning empty.
  The zone choice swaps both zone blocks back onto the strays of the
  layout before the pg-upmap, because they hold six shards against
  five.
- ReturningZone_CurrentShardsKeepTheirZone, epoch 6369: the PG ran on
  the k shards 0(1) and 2(2) while the other zone was down. When it
  returns, the zone choice again moves acting onto the behind strays of
  the old layout (four shards against two), leaving the only shards
  with the newest writes as strays.

All three fail today.

Assisted-by: Claude Code
calc_ec_acting() never gives up a usable up[i] or acting[i]: position i
takes up[i] when it is usable, otherwise acting[i], and only otherwise a
stray.  So acting only moves towards up, and only when up has the data.

calc_ec_acting_stretch() must serve each zone block from one zone, so it
scores whole assignments of zone blocks to zones.  After the relative
shards served (capped at k) it ranked them by the number of usable
shards held, counting strays the same as up and acting shards, and
looked at up and acting only to break ties.  An assignment onto the
strays of an earlier layout therefore beat the one acting was using
whenever the strays held more shards, however far behind they were.  In
a fault-injection run PG 2.39's acting set switched between the layouts
before and after a pg-upmap six times in four minutes.  At epoch 6256
one returning empty up shard (5 shards against 6) swapped both zone
blocks back onto the layout before the pg-upmap.  At epoch 6369 a
returning zone (2 shards against 4) moved acting off 0(1) and 2(2),
which held the only copies of the writes made while the other zone was
down, onto strays 1,641 versions behind; 9 of those writes later became
unfound.

Rank assignments, after the relative shards served, by the positions
they fill from usable up[i] or acting[i], then from up[i], and only then
by the shards held.  Among assignments serving as many relative shards,
strays then only fill positions that up and acting cannot.  The goal
assignment, which decides which up OSDs are backfilled, counts want as
the acting set, since want is what acting becomes.  As before, a
completed backfill makes up's assignment fill as many positions as
want's and win on up[i], so Recovered moves to up.

When acting is pinned by pg_temp to a layout that fills more positions
than up can (for example up moving a zone block onto the zone serving
the other block, with the other block's up OSDs gone), acting now stays
and nothing is backfilled, instead of the PG moving to up: it keeps four
shards in two zones, undersized until the map changes, rather than
moving to three shards in one zone.  The static and end-to-end tests for
that case are restated: the static one now expects acting to stay, and
the end-to-end one checks Recovered dropping the pg_temp after a full
zone block swap.

TestECStretchPeering.ReturningZone_NewestWritesNotUnfound passes.

Assisted-by: Claude Code
calc_ec_acting_stretch() makes a complete, usable up OSD a backfill
target when its zone block will move to it, so that it keeps getting
writes. activate() restarts every complete backfill target that is not
at the head (last_backfill MIN): it is backfilled again from scratch,
and recovery does not use its objects meanwhile. When acting is still
recovering an object that only such shards hold, the object becomes
unfound. calc_ec_acting() never backfills a usable shard, so main does
not hit this.

TestECStretchPeering.ZoneBlockSwap_RestartedUpShardKeptCurrent swaps
the zone blocks of a 2+1 stretch EC PG with a pg-upmap while a pg_temp
keeps the old acting set. All but one of the new up shards finish
backfill; then the OSD of a complete one, x, restarts and misses a few
writes, and more writes follow than the PG log keeps. It expects x to
be caught up from the log rather than restarted, to keep getting
writes, and the PG to move to up when the last backfill finishes. It
fails today: x is restarted.

Two TestECActingStretch tests check which up shards
calc_ec_acting_stretch() backfills. Both pass today.

- ReturningZone_BehindUpShardsKeptAsTargets is a minimised case found
  by a simulation of the peering rules: a zone returns while acting
  (block 1 in dc0) is recovering an object that only dc1 holds, and
  dc1's complete up shards are one write behind. They become backfill
  targets with the empty up shards, so they keep getting writes.
- RandomStates_StableWantAndBackfill checks random up sets, acting
  sets and shard states: the chosen want is chosen again once it is
  acting (no pg_temp ping-pong), want == up comes without backfill,
  and the call from Recovered either moves on or keeps the same
  backfill targets, which choose_acting() asserts.

Assisted-by: Claude Code
An up shard of a multi-zone EC pool can be complete but behind while
its zone block is still served from another zone, for example when its
OSD restarts during a zone block move. It cannot join acting by itself:
a block is served from one zone, so it has to wait until the other up
shards of its zone are backfilled. calc_ec_acting_stretch() makes it a
backfill target, so that it keeps getting writes, and activate() then
restarts it (last_backfill MIN), because it is a complete backfill
target that is not at the head. It is backfilled again from scratch,
and its objects stop counting as recovery sources, which can leave
writes that only it holds unfound.

Keep it a backfill target, and have activate() catch a complete
backfill target of a multi-zone EC pool up from the log instead of
restarting it. activate() still restarts one that is not contiguous
with the log. Other pools are unchanged.

Leaving such a shard out of the backfill targets instead would keep its
objects but send it no writes. During a long backfill it falls off the
PG log. Recovered still counts it as usable, because the primary's
peer_info keeps the log tail from activation, and moves the block to
up; the next interval then leaves its position empty while it is
backfilled from scratch.

Such a target has an accurate missing set and needs no backfill, so
update_calc_stats() counts its missing objects from that set, and
PrimaryLogPG::on_activate_complete() sets up backfill only when a
target needs it (it asserted when every target was complete).

As for any acting shard, a client write to an object such a target is
still missing waits until the object is recovered to it.

TestECStretchPeering.ZoneBlockSwap_RestartedUpShardKeptCurrent passes.

Assisted-by: Claude Code
chaos.py's upmap_items picked a random entry of the PG's up set.  While
a zone is down a PG can have no up OSDs at all, and random.choice() on
the empty list ended a run with IndexError; an entry for a missing
position (CRUSH_ITEM_NONE) was also a possible pick and made the action
a no-op. Pick only up OSDs the tool knows, and skip the PG if there are
none.

Assisted-by: Claude Code
setup_cluster.sh creates a two-zone replicated test pool with 'osd pool
create ... --num_zones 2 --num_replica_per_zone N'. Commit 8b30768
("mon: add per-zone replica configuration for stretch pools") renamed
that argument to --replica, and the ceph command now rejects
--num_replica_per_zone as an unexpected argument, so setup of a -p
replicated -z 2 run fails. Take the argument name from the monitors'
command description of 'osd pool create', which the script already
reads to find num_zones, so builds from before and after the rename
both work.

Assisted-by: Claude Code
…ones

setup_cluster.sh created the rbd workload's metadata pool with 'osd pool
create rbd 8 8 replicated $rule'. In global stretch mode $rule is the
stretch rule, but with a --num_zones test pool it is empty, so the rbd
pool got the default rule: size 3, min_size 1, with no regard for
zones. Writes acknowledged only by OSDs of one zone are then lost when
that zone fails; a run on a two-zone EC 2+1 pool ended with
rbd_directory unfound in PG 3.4 of the rbd pool.

Where the test pool is a --num_zones pool, create the rbd pool the same
way as a replicated test pool: --num_zones 2 with 2 replicas per zone
and an OSD failure domain. Global stretch mode and single-zone runs are
unchanged.

Assisted-by: Claude Code
chaos.py took a pool's num_zones from the "options" of the pool in 'osd
pool ls detail'. Since 8b30768 ("mon: add per-zone replica
configuration for stretch pools") num_zones is a pool field that the
pool dump does not show, so chaos.py fell back to the global stretch
mode path: the pool has peering_crush_bucket_count set and the OSD map
has stretch_mode_enabled, which a --num_zones pool also enables. The
zones came out right from stretch_bucket_count, but the pool line and
the run summary called a --num_zones pool "(global stretch mode)".

Read num_zones with 'ceph osd pool get <pool> num_zones', which fails
on monitors without num_zones (main), and take global stretch mode from
the monitor map: global_stretch_mode where the monitors have per-pool
stretch mode, otherwise stretch_mode, the only kind on main.

Assisted-by: Claude Code
chaos.py's docstring said the osds_first zone failover variant does not
nudge the monitors. Every variant does: when stretch mode is still
degraded and not recovering --nudge-after seconds after the revive, with
full quorum, ZoneFailover.step() records a finding and runs 'osd
force_recovery_stretch_mode'. Describe that for zone_failover as a
whole and drop the claim from osds_first, whose only difference is the
order of the revive.

Assisted-by: Claude Code
setup_cluster.sh set fixed log levels after vstart -d: debug_osd 1/20,
debug_ms 0/5 and the BlueStore levels in the OSDs' configuration, and
debug_mon 1/20, debug_ms 0/5 and debug_paxos 1/10 on the monitors with
'ceph tell'. So the OSD logs of a run that stopped on a stuck op showed
almost nothing about it, and getting more meant editing the script.
Higher levels cost a lot of disk space, so they should be a choice.

run_chaos.sh -l picks a preset, passed to setup_cluster.sh as
LOG_LEVELS:
- default: the levels above, as before.
- low: also writes only level 1 to the file for the OSDs' monc,
  objecter, mgrc, reserver and objclass and for the manager, which
  vstart -d logs at 10 to 20.
- high: debug_osd and debug_mon 20 and debug_ms 1 on the OSDs and
  monitors.
run_chaos.sh -D (DEBUG_LEVELS) adds levels after the preset, as
comma-separated [osd:|mon:|mgr:]SUBSYS=LEVEL[/MEMLEVEL], for all three
daemon types without a prefix. run_chaos.sh checks both before it
touches the cluster, and the summary's config line shows them.

All levels now go in the configuration database, so that daemons that
chaos.py or upgrade_cluster.sh restart keep them, and 'ceph config set'
changes them during a run. A monitor's ceph.conf debug lines override
the database, so setup_cluster.sh deletes them instead of rewriting
them, sets the levels that it wrote there (1/20 for debug_osd,
debug_auth and debug_mgrc) in the database, and gives the running
monitors, which read ceph.conf at startup, the same levels with 'ceph
tell'. A monitor started later now keeps debug_paxos 1/10, where it
used to get 1/20 from ceph.conf.

The usage text gives the disk cost. Creating the cluster logs up to
1G. In a two-zone EC 2+1 run the daemon logs then grew by about 0.3G
an hour at the default levels (a 95 minute run), about 0.1G with low
(an estimate from that run's logs without the lines that low drops)
and about 65G with high (12 minutes of a short run, almost all of it
debug_osd 20 on the OSDs). run_chaos.sh warns when -l high is given.

Assisted-by: Claude Code
…es out

Follow-up for Callum James to review and squash into "WIP: ec stretch
zone thrasher".

_wait_for_degraded_stretch() and _wait_for_healthy_stretch() are meant
to raise RuntimeError on timeout, and _do_thrash() catches RuntimeError
from the degraded wait to revive the zone before propagating the error.
But safe_while's proceed() raises MaxWhileTries when its tries run out,
so the RuntimeError after each loop is never reached and the handler
never runs: a degraded wait that times out leaves the zone's OSDs and
monitor down for the rest of the job. A timed-out healthy wait (job
611913: "'wait for healthy stretch mode' reached maximum tries (60)")
also failed with MaxWhileTries rather than the thrasher's own message.

Pass _raise=False, so that proceed() returns False when the tries run
out and the loops end in their RuntimeError.

Assisted-by: Claude Code
…eError

Follow-up for Callum James to review and squash into "qa: wait for
stretch pool to exist before starting thrasher".

As in the waits for degraded and healthy stretch mode, safe_while
raised MaxWhileTries before _wait_for_stretch_pool() reached the
RuntimeError that its docstring promises. Nothing is down yet at that
point, so only the error changes: pass _raise=False so that the job
fails with "Timed out waiting for stretch pool to exist".

Assisted-by: Claude Code
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
(cherry picked from commit c2b72df)
Add unittest_io_sequence, which steps every IoSequence through to Done
without a cluster.

ceph_test_rados_io_sequence only checks consistency when run with
--checkconsistency, and RadosIo only has a consistency checker for an
erasure coded pool. Every sequence but Seq16 honours check_consistency;
Seq16 issues a Consistency op after every TruncateWrite regardless, so
any run on a replicated pool that reaches Seq16 fails
ceph_assert(cc) in RadosIo::applyIoOp().

NoConsistencyOpsUnlessRequested fails for Seq16 only.
Seq16ChecksConsistencyWhenRequested, which checks the checks still
happen when asked for, passes.

Fixes: https://tracker.ceph.com/issues/81389
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit 815ce72)
Seq16 issued a Consistency op after each TruncateWrite whether or not
the run asked for consistency checks. On a replicated pool, which has
no consistency checker, ceph_test_rados_io_sequence then failed
ceph_assert(cc) as soon as it reached Seq16, for example with
"--pool <replicated> --sequence 16,16".

Issue the Consistency op only when check_consistency is set, as the
other sequences do, and otherwise just a barrier.

Fixes: https://tracker.ceph.com/issues/81389
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit db6c8df)
The Consistency case in RadosIo::applyIoOp() had no break, so every
consistency check went on to run the Copy case and copy the primary
object over the secondary one. The model does not see that copy, so a
later read of the secondary object could miscompare.

Add the missing break.

Fixes: https://tracker.ceph.com/issues/81389
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit b0c9ced)
…ight

ObjectModel only stops a read that overlaps an in-flight Write, and
ceph_test_rados_io_sequence relies on each sequence's barriers for
everything else. Seq15 copies onto the original object and truncates it
with no barrier before the next read of that object, so the read can be
sent while the copy_from and the truncate are still in flight.

A read sent to the primary is ordered behind them there. A balanced read
can reach a replica before either write does and return the object as it
was before the copy: a run on a replicated pool with
--balanced_read_percentage 100 and 4 object threads failed this way.

NoReadWhileWholeObjectWriteInFlight steps every sequence and fails when a
read of an object follows a copy, truncate, create or remove of it
without a barrier. It fails for Seq15 only.

Fixes: https://tracker.ceph.com/issues/81389
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit e06c4fe)
Seq15 issued its copy_from and its truncate without a barrier, so the
read of the copy target that follows could overtake them. With balanced
reads that read could reach a replica before either write and see the
object as it was before the copy, which ceph_test_rados_io_sequence
reported as a miscompare.

Issue a barrier after both, so the read only starts once they are done.

Fixes: https://tracker.ceph.com/issues/81389
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit 114c94a)
When no test object can start an I/O, the main loop of
run_automated_test() rechecks readiness under the lock, as the comment
above it says it should before waiting on the condition variable, but
then never waits. It loops straight round, so the main thread spins on
the lock for as long as any I/O is outstanding: about 65 CPU seconds a
minute with --parallel 1, against 12 once it waits. A run left behind
after its cluster went away spun at 100% for 14 hours.

Wait on the condition variable that RadosIo signals under the same lock
whenever an I/O completes. An object that is not ready always has I/O
in flight, so a completion will wake the loop.

Fixes: https://tracker.ceph.com/issues/81389
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit 4ec6906)
…ences

Answers two of Jon Bailey's review comments on
ceph#72383.

On the step limit in NoConsistencyOpsUnlessRequested, which he asked to
have a comment saying why it is there
(ceph#72383 (comment)): the
limit is only in this unit test, not in ceph_test_rados_io_sequence.
Move it into run_sequence(), which every test in the file uses to step a
sequence to Done, with a comment saying it makes a sequence that never
reaches Done fail with its name instead of hanging until the ctest
timeout, and lower it from 10,000,000 to 1,000,000. The longest sequence
here, Seq14, takes 29,255 steps.

On the hardcoded skip of Seq10, which he asked to leave to
getNextSupportedSequenceId() or is_supported()
(ceph#72383 (comment)): add
supported_sequences(), which walks the sequences with
getNextSupportedSequenceId() as ceph_test_rados_io_sequence does, and
loop over that. generate_sequence() aborts for Seq10, so each next
sequence is asked of the one before it.

To be squashed into "test/osd: demonstrate io_sequence Seq16 checking
consistency unasked" before merge.

Assisted-by: Claude Code
(cherry picked from commit 32c0d60)
Answers Jon Bailey's review comment on
ceph#72383
(ceph#72383 (comment)), which
asked for Seq16 to set consistency from check_consistency and return a
barrier, so that the check always follows a barrier and Seq16 matches
Seq5 to Seq9.

Do that. IoSequence::next() then issues the Consistency op, followed by
another barrier, only when check_consistency is set. Seq16 still issues
20 TruncateWrites; with check_consistency it now issues an extra barrier
before each of its checks, and without it the ops are unchanged.

To be squashed into "common/io_exerciser: only check consistency in
Seq16 when asked" before merge. Its body should then say "set
consistency from check_consistency and return a barrier, as Seq5 to
Seq9 do" instead of "otherwise just a barrier".

Assisted-by: Claude Code
(cherry picked from commit 1656902)
Answers two of Jon Bailey's review comments on
ceph#72383.

On the hardcoded skip of Seq10, which he asked to leave to
getNextSupportedSequenceId() or is_supported()
(ceph#72383 (comment)): loop
over supported_sequences(), as NoConsistencyOpsUnlessRequested now does.

On the default case of the switch over OpType, which he asked to replace
with the missing cases so that a new op has to be considered here
(ceph#72383 (comment)): give
every OpType a case and drop the default. Consistency reads the object,
so it is checked like a read. The ops that do not rewrite a whole object
need nothing. A plain build only warns (-Wswitch) about a missing case,
but make check builds with -Werror, where it fails.

To be squashed into "test/osd: demonstrate Seq15 reading while a copy or
truncate is in flight" before merge.

Assisted-by: Claude Code
(cherry picked from commit a7d73d0)
In an optimized EC pool, a sub-stripe write gives the shards it does not
touch a partial_writes_last_complete (pwlc) range ending at that write.
If peering later rolls the write back, a pwlc range that still ends at
it is stale, and applying it moves a nonprimary shard's last_update and
log head to a version that no longer exists.

ceph#71579 ("osd: pwlc was able to retain values larger than the
last_update") trims the pwlc copies the primary holds for divergent
peers in proc_replica_log, but the primary's own copy is not trimmed.
The new primary merges each peer's pwlc in update_peer_info() during
GetInfo, before GetLog has decided the authoritative log, so it keeps a
range ending at a write that peering then rolls back. proc_master_log()
would trim it, but does not run when the primary is its own log source.
activate() then stamps the stale range with a new epoch, making it the
definitive copy, and sends it to the peers. The nonprimary shards apply
it and move their last_update and log head to the rolled-back version,
so the next write to them, which reuses that version number, asserts in
IndexedLog::add; a shard left with such a last_update can also be picked
later as the log source and then never be recovered.

The primary's log is authoritative once it activates, so no pwlc range
may end past its head. activate() now trims pwlc to the head before
stamping the epoch, which also covers ranges merged after GetLog in
WaitUpThru and from peers whose log head already matched.

A nonprimary shard keeps its own pwlc too, and update_peer_info()
applies its own range after merging only the ranges the primary sends.
When no primary-capable shard of the new interval saw a partial write
that skipped it, the primary sends no range for it, so the shard applies
its stale range again right after the primary's MInfoRec has rewound
its log. update_peer_info() now trims a nonprimary shard's pwlc to the
primary's last_update before applying it.

The range for its own shard that a replica applies from an MLogRec
before merging the log is capped at the sender's last_update the same
way. With the activate() change a primary no longer sends such a range;
the cap is defensive, for mixed-version clusters during an upgrade where
the primary still runs older code.

Tested by TestECFailoverWithPeering.RolledBackPeeredWriteLeavesNoStalePwlc
and RolledBackPeeredWriteLeavesNoStaleReplicaPwlc in the following commit.

Fixes: https://tracker.ceph.com/issues/81283
Assisted-by: Claude Code

Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit 5251dff)
Tests "osd/PeeringState: cap pwlc at the log head when the primary
activates".

A sub-stripe write kept by a peered interval gives the unwritten
nonprimary shards a pwlc range ending at that write. When the
primary-capable shard that missed the write returns, the write is rolled
back. RolledBackPeeredWriteLeavesNoStalePwlc checks that the new primary
does not keep, stamp and send the old range it merged from another
primary-capable shard, so the nonprimary shards do not move their
last_update and log head to the rolled-back version, and the next write,
which reuses that version number, succeeds.

A nonprimary shard also keeps its own copy of that range.
RolledBackPeeredWriteLeavesNoStaleReplicaPwlc covers a write that
reaches no other primary-capable shard, so no primary of the next
interval has a range for the nonprimary shards, and checks that they do
not re-apply their own copy after the new primary's MInfoRec rewinds
them.

Both tests raise the pool's min_size to k + 1 so that losing two shards
leaves the PG peered but not active. They check the state before the
next write so a regression fails the test rather than aborting the
binary. Adds OSDMapTestHelpers::set_pool_min_size() and
ECPeeringTestFixture::set_pool_min_size() for this.

The tests do not deep-scrub the object afterwards: shard 0 is down by
then, and a deep scrub of an ISA pool with a data shard missing reports
data digest errors even for an object that was never partially written.

On stretchy-C, ECPeeringTestFixture::set_pool_min_size() already exists, so
only the tests are carried.

Assisted-by: Claude Code

Signed-off-by: Alex Ainscow <[email protected]>

(cherry picked from commit 158e0d0)
@kamoltat kamoltat closed this Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants