Skip to content

mon: stretch pool create, stretch mode and stretch command fixes for stretchy-C - #43

Closed
aainscow wants to merge 43 commits into
stretchy-Cfrom
wip-stretchy-C-mon-review
Closed

aainscow wants to merge 43 commits into
stretchy-Cfrom
wip-stretchy-C-mon-review

Conversation

@aainscow

@aainscow aainscow commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Monitor fixes for stretch erasure coded pools on stretchy-C. They cover osd pool create --num_zones, how a multi-zone pool works with stretch mode (both global stretch mode and the stretch mode a 2-zone pool create enables), and the individual stretch pool commands ceph osd pool stretch set and unset. The fixes were developed and tested on one long branch and are consolidated here into one commit per fix. Each fix commit holds its standalone test, the qa changes it needs, and its changes to the design (doc/dev/osd_internals/erasure_coding/ec_stretch_cluster.rst) and user docs.

43 commits on stretchy-C (6583a08), 35 files, +2089 -756:

  • Part A (A01-A15): main-bound commits that Part B needs, carried until stretchy-C is rebased onto a main that has them. They need no review here.
  • Part B (B01-B28): the stretchy-C work.

Part A: carried main-bound commits

Each keeps the change and message of its main version, with a first paragraph added: "Carried from ...; drop when stretchy-C is rebased onto a main that has it". A02, A09 and A12 differ from main only where stretchy-C's context differs (see below). Jamie Pryde's commit (A04) is byte-identical, with no added paragraph; the test before it (A03) carries the note for both. Part B needs them: B05's test needs A02, B08's failed-create test needs A04, and B02 and B12 build on A08 and A11.

When stretchy-C is rebased onto a main that has these, twelve of them drop by patch-id. Three must be dropped by hand:

  • A02 has the same lines as main's version, but different hunk context.
  • A09 and A12 edit stretchy-C's story 4a in the design doc, which says "num_zones > 1" where main says "zones > 1".

Part B: stretchy-C commits

  • B01 qa/standalone: use the auth_*_required options in crush-stretch.sh. Every test in that script failed at the first run_mon, because ceph-mon no longer accepts --auth-supported.
  • B02 test/librados: create the stretch EC test pool with num_zones. The old setup used stretch set, which A08 refuses for an EC pool, and osd pool set num_zones, which B16 refuses. The pool is now created with one osd pool create carrying k, m and num_zones 2.
  • B03 qa/standalone: add helpers for the mon-stretch tests. Adds mon-stretch-helpers.sh, which the new mon-stretch scripts source. It provides run_stretch_tests, wait_for_stretch_state, pool_field, two_zone_cluster (with an optional number of OSDs per datacenter), ec_stretch_cluster_without_dc2 and enable_global_stretch_mode.
  • B04 doc/dev: ec_stretch_cluster: describe a pool created in degraded stretch mode. Section 11.4.3 describes the pool A02 creates. The 11.6 table is corrected: the transitions never change peering_crush_bucket_target.
  • B05 mon/OSDMonitor: keep degraded stretch mode when a stretch EC pool is created.
    • Before: creating a --num-zones 2 pool with a zone down reset degraded_stretch_mode, which ended degraded mode without the healthy transition. The lost zone's monitor stayed marked down, so losing the other zone then left no quorum.
    • Now: the cluster's stretch state is written only when stretch mode is not already enabled, and the new pool gets the degraded values the other pools have.
    • Test: mon-stretch-ec-pool-create-degraded.sh.
  • B06 mon/OSDMonitor: size a replicated stretch pool from its zones.
    • Before: a --num-zones 2 replicated pool created without a size got osd_pool_default_size (3), so one zone held a single replica.
    • Now: it gets num_zones * num_replica_per_zone (4) and the matching min_size.
    • Test: TEST_pool_create_stretch_replica in crush-stretch.sh.
  • B07 mon/OSDMonitor: use the stretch rule for a pool created in global stretch mode.
    • A pool created without a rule in global stretch mode now gets the stretch rule, as on main.
    • --root, --zone_failure_domain, --osd_failure_domain and --class would have no effect there, so they are refused instead of ignored.
    • Test: mon-stretch-pool-create-global-rule.sh.
  • B08 mon/OSDMonitor: enable stretch mode only once a pool create has passed every check.
    • Before: a 2-zone pool create that failed a later check (for example differing datacenter weights) left the monitors in stretch mode.
    • Now: the stretch settings are validated where they were but applied at the end of prepare_new_pool().
    • Tests: mon-stretch-failed-create-mons.sh and mon-stretch-failed-pool-create.sh. The second relies on A04.
  • B09 doc,qa: describe the erasure code profile lifecycle.
    • A profile is created by osd erasure-code-profile set or by osd pool create with k and m, and it is deleted with the last pool that uses it.
    • This is described in the user docs and in a new section 2.1.5 of the design.
    • mon/osd-crush.sh and the teuthology rados task no longer reuse a deleted profile.
  • B10 mon: keep the legacy positional arguments of osd pool create.
    • The new stretch parameters were inserted after rule, so a legacy positional create passed expected_num_objects as num_zones.
    • They now follow --, so they can only be given by name.
    • Test: mon-stretch-pool-create-positional.sh.
  • B11 mon/OSDMonitor: require k and m for a multi-zone EC pool.
    • osd pool create <pool> erasure --num_zones 2 without k and m used to take the default profile. It also turned the shared erasure-code rule into a two-datacenter rule, which later single-zone EC pools then used. It is now refused.
    • Test: mon-stretch-pool-create-multi-zone-km.sh.
  • B12 mon/OSDMonitor: refuse stretch set and unset while multi-zone pools exist.
    • Both commands are also refused while global stretch mode is enabled in the monitor map, and while any committed or pending pool has num_zones > 1. A num_zones 3 pool enables no stretch mode, so A11's check alone does not cover it.
    • refuse_in_stretch_mode() becomes an OSDMonitor member. The search is find_multi_zone_pool(), built on find_pool(), which finds the first committed or pending pool that a predicate accepts.
    • Docs: design 2.1.5, 11.4.1 and story 4a, and doc/rados.
    • It keeps the refusal of "mon: Prevent osd pool stretch set for EC", and leaves the Per-Pool Stretch Mode paragraph of stretch-mode.rst as that commit worded it. B16 follows up both.
    • Tests: mon-stretch-multi-zone-stretch-set.sh, with two tests.
  • B13 mon/OSDMonitor: refuse a multi-zone pool in global stretch mode.
    • osd pool create refuses num_zones > 1 while global stretch mode is enabled or being enabled. The check runs before an EC pool's generated profile is created, so that profile is not left behind.
    • validate_stretch_mode_new_pool() then has no caller left. It is removed, along with extract_sites_from_crush_rule() and their 5 unit tests.
    • crush-stretch.sh drops TEST_stretch_diff_sites and reduces TEST_stretch_diff_bucket_barrier, which tested that validation.
    • Test: mon-stretch-global-mode-multi-zone.sh.
  • B14 mon/OSDMonitor: refuse global stretch mode while multi-zone pools exist.
    • ceph mon enable_stretch_mode is refused while any committed or pending pool has num_zones > 1. It would otherwise manage that pool as a legacy stretch pool.
    • Docs: design 11.4.2 and story 4b.
    • Test: in mon-stretch-global-mode-multi-zone.sh.
  • B15 mon/OSDMonitor: refuse placement options for a single-zone replicated pool.
    • The placement options were accepted and ignored for a replicated pool with no rule and num_zones 1. They are now refused.
    • The global stretch mode refusal from B07 is reworded to point at --rule.
    • Test: mon-stretch-replicated-placement-options.sh.
  • B16 mon/OSDMonitor: refuse osd pool set num_zones.
    • Before: when sent as a mon command, osd pool set num_zones was accepted and resized an EC pool, leaving its rule and stretch values for the old zone count. Changing num_zones is a later release (design 13.2).
    • Now: the variable is refused, and the EC resize is dropped.
    • Test: mon-stretch-set-num-zones.sh.
    • Follow-up to "mon: Prevent osd pool stretch set for EC", which pointed users at ceph osd pool set <pool> num_zones <N>. Its refusal in stretch set is removed: A08 refuses every EC pool before it, and it names the command B16 refuses. The pools.rst note and two stretch-mode.rst sentences now say that a multi-zone pool, replicated or erasure coded, is created with ceph osd pool create ... --num-zones, and that num_zones cannot be changed afterwards. These hunks can be squashed into that commit once it comes after A08 and after B16's refusal (see the notes for reviewers).
  • B17 doc/rados: create a stretch pool with --num-zones. The "Creating Stretch Pools" example in stretch-mode.rst, which B16's sentences link to, used zone=2, which the monitor refuses ("error parsing integer value 'zone=2'"). It now uses --num-zones 2.
  • B18 qa/tasks/ceph_manager: create multi-zone EC pools from k and m. teuthology's create_pool passed the suite's erasure code profile name together with --num_zones, which the monitor refuses, so the num_zones 2 pools of thrash-erasure-code-big and thrash-erasure-code-stretch could not be created. It now sets up the <pool>-k<k>-m<m> profile with the named profile's keys and creates the pool with --k, --m and --num_zones.
  • B19 qa/tasks: build a two-zone custom rule for a multi-zone EC pool. The erasure_code_crush variant built a one-zone rule for a 2-zone pool, which spread each zone's block of shards over both datacenters. It now builds the rule with --num_zones.
  • B20 mon/OSDMonitor: refuse enable_stretch_mode while erasure coded pools exist.
    • This restores main's refusal and message. Global stretch mode is the legacy stretch mode and keeps main's behaviour.
    • The unittest_osd_monitor EC tests now expect the refusal.
    • Test: mon-stretch-enable-ec-pool.sh.
  • B21 doc/dev: ec_stretch_cluster: a 2-zone pool create enables stretch mode. Covers the Pool Creation Gate of 11.4.2, the 11.1 prerequisites table, the 11.3 state diagram, and section 15, where FastEC is the only release check.
  • B22 doc/dev: ec_stretch_cluster: describe min_size as section 11.2.1 does.
    • In healthy stretch mode a PG needs min_size + k + m shards in total; in degraded and recovery stretch mode it needs min_size shards in the surviving zone. The monitor does not change an EC pool's min_size.
    • It also recorded that the transitions still halved and reset the min_size of every replicated stretch pool, num_zones 2 pools included, as a difference from section 11.2. B27 changes that, and B28 updates the doc.
  • B23 mon/OSDMonitor: refuse a multi-zone pool while individual stretch pools exist.
    • osd pool create refuses num_zones > 1 while any committed or pending pool is an individual stretch pool, meaning one with stretch values and num_zones 1. Before, the stretch mode that the new pool enabled went on to change that pool in its transitions.
    • The check sits next to B13's, before any profile or rule is created. The pool is found with find_pool(), as in B12.
    • Test: TEST_multi_zone_pool_create_with_stretch_pool.
  • B24 test/mon: demonstrate an umbrella monmap decoding as global stretch mode. Two new unittest_mon_monmap tests set stretch_mode_enabled, encode the monmap with all features (which include SERVER_UMBRELLA) and decode it. They expect global_stretch_mode_enabled to come back as it was set. With it set to false, the test fails until B25.
  • B25 mon/MonMap: encode the umbrella monmap as struct version 11.
    • Before: "mon/MonMap: Return early from encoding if before umbrella" encoded the umbrella monmap as version 10, but still appended global_stretch_mode_enabled, a version 11 field. MonMap::decode() reads that field only from version 11, and otherwise sets it to stretch_mode_enabled. So once a 2-zone pool create enabled stretch mode, every monitor saw global stretch mode enabled too, and B13 refused later num_zones > 1 creates, including that create when it was resent after the election. TEST_pool_create_stretch_ec and TEST_pool_create_stretch_replica in crush-stretch.sh, and TEST_multi_zone_pool_create_with_stretch_pool and TEST_stretch_pool_commands_with_two_zone_pools in mon-stretch-multi-zone-stretch-set.sh, failed because of it.
    • Now: the umbrella monmap is encoded as version 11 again, as before that commit. compat_v stays 6, so a decoder that knows only version 10 skips the last field.
    • Test: B24.
    • Follow-up to "mon/MonMap: Return early from encoding if before umbrella". It can be squashed into that commit (see the notes for reviewers).
  • B26 qa/standalone/mon-stretch: demonstrate stretch transitions changing a multi-zone pool's min_size.
    • TEST_multi_zone_replicated_min_size in the new mon-stretch-multi-zone-min-size.sh creates replicated --num-zones 2 pools with the default min_size (2) and with min_size 1, loses a zone, creates another min_size 1 pool in degraded stretch mode, and brings the zone back. It expects every pool to keep its min_size, and fails until B27.
    • TEST_global_stretch_mode_min_size checks that a pool in global stretch mode still has its min_size halved on the degraded transition and set to mon_stretch_pool_min_size on the healthy one, as on main.
    • lose_dc2 and restore_dc2 move the zone loss and return of mon-stretch-ec-pool-create-degraded.sh into mon-stretch-helpers.sh.
  • B27 mon/OSDMonitor: keep a multi-zone pool's min_size on stretch mode transitions.
    • Before: the degraded transition halved the min_size of every replicated stretch pool, and the healthy transition set it to mon_stretch_pool_min_size (2), num_zones 2 pools included. A pool created with min_size 1 went to 0 in degraded stretch mode and to 2 once healthy again, and stayed at 2.
    • Now: both transitions leave the min_size of a pool with num_zones > 1 alone, as section 11.2 of the design intends. Legacy stretch pools (num_zones 1: global stretch mode and individual stretch pools) keep main's behaviour.
    • Default min_size: a --num-zones 2 pool with two replicas per zone gets min_size 2, the default for its size of 4. The degraded transition used to lower it to 1. It now stays 2, so in degraded stretch mode its PGs need both copies in the surviving zone. With min_size 1 such a pool behaves as the default pool did before, in every stretch mode state. See the open question in the notes below.
    • Test: B26.
  • B28 doc: stretch mode transitions keep a multi-zone pool's min_size.
    • Design sections 11.3, 11.4.3 and 11.4.4, where B22 recorded the old behaviour as a difference from 11.2, and 11.4.2 for a pool created in degraded stretch mode.
    • Section 11.3 also says that the OSD counts min_size per zone only for EC pools: a replicated multi-zone PG needs min_size replicas in its acting set, with one in each zone while healthy and all in the surviving zone while degraded.
    • In stretch-mode.rst, the stretch mode overview now limits the drop to min_size 1 to global stretch mode. The Per-Pool Stretch Mode paragraph says that the loss and return of a zone do not change a --num-zones pool's min_size, and that while a zone is down its PGs need min_size copies or shards in the surviving zone.

Testing

This series was rebased onto stretchy-C 6583a08, which adds Eric Zhang's "mon/MonMap: Return early from encoding if before umbrella" and "mon: Prevent osd pool stretch set for EC". B25 follows up the first of them.

On the tip, 9bf0d84 (only the tip was built and run, not the commits one by one, apart from B24's and B26's tests):

  • Build: a full ninja -j20 (incremental, from a full build of 3a12053), then ninja -j20 unittest_osd_monitor unittest_osdmap unittest_mon_monmap, passed with no errors or warnings.
  • Unit tests: unittest_mon_monmap passed 4/4 (its 3 disabled tests stay disabled), unittest_osd_monitor passed 11/11 (B13 removes 5), and unittest_osdmap passed 46/46. On an earlier run of unittest_osdmap, OSDMapTest.rb_osdsize_opt_score failed once; its upmap balancing shuffles with a random seed, it then passed 30 runs on its own, and this series does not touch src/osd.
  • B24's test without B25: built and run at B24, MonMapEncode.umbrella_stretch_mode_without_global failed with "Value of: m.global_stretch_mode_enabled, Actual: true, Expected: false". The other three unittest_mon_monmap tests passed.
  • B26's test without B27: built and run at B26, TEST_multi_zone_replicated_min_size failed at its first check in degraded stretch mode, where the default pool had min_size 1 and the min_size 1 pool had min_size 0. A copy of the test that logs the values instead of failing showed all three pools at min_size 2 after the healthy transition. TEST_global_stretch_mode_min_size passed. With B27 both tests pass (below).
  • Standalone tests, run one at a time. All passed, with no cores. Times include setup and teardown and are to about 10 s.
    • every qa/standalone/mon-stretch script:
      • mon-stretch-commands.sh (4 tests, 291 s)
      • mon-stretch-ec-pool-create-degraded.sh (321 s)
      • mon-stretch-enable-ec-pool.sh (90 s)
      • mon-stretch-fail-recovery.sh (250 s)
      • mon-stretch-failed-create-mons.sh (140 s)
      • mon-stretch-failed-pool-create.sh (10 s)
      • mon-stretch-global-mode-multi-zone.sh (2 tests, 181 s)
      • mon-stretch-multi-zone-min-size.sh (2 tests, 330 s)
      • mon-stretch-multi-zone-stretch-set.sh (3 tests, 361 s)
      • mon-stretch-pool-create-degraded.sh (210 s)
      • mon-stretch-pool-create-global-rule.sh (90 s)
      • mon-stretch-pool-create-multi-zone-km.sh (10 s)
      • mon-stretch-pool-create-positional.sh (20 s)
      • mon-stretch-replicated-placement-options.sh (10 s)
      • mon-stretch-set-num-zones.sh (10 s)
      • mon-stretch-uneven-crush-weights.sh (160 s)
    • crush/crush-stretch.sh (9 tests, 971 s)
    • mon/osd-pool-create.sh (19 tests, 491 s)
  • Before B25, four of these tests failed on this series: TEST_pool_create_stretch_ec and TEST_pool_create_stretch_replica in crush-stretch.sh, and TEST_multi_zone_pool_create_with_stretch_pool and TEST_stretch_pool_commands_with_two_zone_pools in mon-stretch-multi-zone-stretch-set.sh. In each, after a 2-zone pool create enabled stretch mode, the committed monmap decoded with global stretch mode enabled too, and B13 refused the create when it was resent after the election (see B25). They pass at the tip.
  • B17's example was run on a 2-zone cluster with the tip's monitor code (B23 with B25's change made locally): ceph osd pool create mypool 32 32 replicated my_stretch_rule --num-zones 2 created a size 4 pool with num_zones 2 on that rule, and its PGs went clean. The old zone=2 form was refused with "error parsing integer value 'zone=2'".
  • git log --check is clean. docutils on the four changed .rst files reports only unknown Sphinx directives and roles; pools.rst has one more prompt directive than before the rebase, and B28 adds no message.
  • Not run:
    • The qa/tasks changes in B09, B18 and B19 were not run in teuthology. B19's commands were replayed on a standalone cluster, as its message says.
    • B02's librados test. It was built before the rebase, but not run.
    • The docs were not built with Sphinx.

Before the rebase, testing was done on the branch this series was consolidated from (74 commits, tip c899e84cf13, on stretchy-C fb56ba2). Its tree, 7999c4a51ee, differed from this series' tree before the rebase (6593cfcbb1f) only by one line of the design doc: section 11.4.1 no longer says "as on main". Before B26, the tree differed from 6593cfcbb1f only in src/mon/MonMap.cc (Eric's first commit and B25), in src/test/mon/MonMap.cc (B24), in crush-stretch.sh (Eric's second commit removed the two stretch set commands from TEST_stretch_ec_stretch_set), and in pools.rst and stretch-mode.rst (Eric's heading underline, B16's rewording of his note and two sentences, and B17's example), and src/mon/OSDMonitor.cc was identical. B26-B28 then change src/mon/OSDMonitor.cc (B27), three mon-stretch scripts (B26) and two docs (B28). The standalone runs above replace the ones made there. These earlier results were not repeated on the tip:

  • Full build with -k 0: ninja -k 0 -j20 passed with no errors or warnings. The full build of the tip above was incremental.
  • On an earlier tip of the source branch with the same ceph-helpers.sh as this tip, qa/standalone/ceph-helpers.sh TESTS test_run_mon test_activate_mon passed. On a still earlier tip, with the same MonCommands.h and osd-crush.sh but before A06 split activate_mon out of run_mon in ceph-helpers.sh, src/test/pybind/test_ceph_argparse.py gave 139 OK and mon/osd-crush.sh passed 9/9.
  • Without the fix: each fix commit's message says how its test fails without the fix. Those results come from runs against a ceph-mon built without the fix, made when each test was written.
    • B23 was checked at the source tree. With its src/mon change reverse-applied, TEST_multi_zone_pool_create_with_stretch_pool failed: the monitor answered "pool 'rep2' created" while rep was stretched.
    • TEST_stretch_pool_commands_with_two_zone_pools (B12) passes without B12's fix, as expected, because A11 already refuses both commands once a 2-zone pool has enabled stretch mode.
    • B12's three-zone test was run against the unfixed monitor in its earlier order, and it failed then. It was later reordered because B23 refuses its old setup. That the reordered test still fails without the fix comes from reading the code.

Notes for reviewers

  • For Eric Zhang: two commits follow up your stretchy-C commits, for you to review and squash. This series is rebased onto both and keeps them unchanged.
    • B16 follows up "mon: Prevent osd pool stretch set for EC". The series keeps that commit's crush-stretch.sh change, and B16 is the only commit that changes its lines. B16's last hunks adjust it to B16's refusal of osd pool set num_zones: they remove its refusal in prepare_command_pool_stretch_set(), and rewrite the pools.rst note and the two stretch-mode.rst sentences it changed. In those two sentences they also replace stretchy-C's own zone parameter and zone=N wording, which that commit did not change. They are for Eric to review, and to squash into his commit once it comes after A08 and after B16's refusal. Squashed where it is now, they would let stretch set accept an EC pool of any size until A08, since that commit already removed the old EC checks, and the docs would say that num_zones cannot be changed while the monitor still accepts osd pool set num_zones.
    • B25 follows up "mon/MonMap: Return early from encoding if before umbrella". It sets the version of the umbrella encoding back to 11, because that encoding still ends with the version 11 field global_stretch_mode_enabled. It can be squashed into that commit without conditions. B24's test then passes from its own commit on, so the last sentence of B24's message ("MonMapEncode.umbrella_stretch_mode_without_global fails on the current code.") should be dropped when B25 is squashed.
  • Erasure coded pools and the legacy commands:
    • stretch set refuses erasure coded pools (A08). stretch unset can then only meet an EC pool that an older release stretched, and accepts it only with size k+m and min_size between k and k+m.
    • ceph mon enable_stretch_mode is refused while any EC pool exists, with main's message (B20), because global stretch mode is the legacy stretch mode.
    • A multi-zone EC pool gets its stretch values only from osd pool create --num_zones, and osd pool set num_zones is refused (B16).
  • Individual stretch pools vs stretch mode and multi-zone pools. These are kept exclusive:
    • stretch set and unset are refused while stretch mode is enabled (A11), whether it is global or started by a num_zones 2 create. They are also refused while global stretch mode is enabled in the monitor map, and while any pool has num_zones > 1 (B12).
    • A num_zones > 1 create is refused in global stretch mode (B13) and while an individual stretch pool exists (B23).
    • enable_stretch_mode is refused while a multi-zone pool exists (B14).
    • These checks count committed and pending pools alike. So a stretch unset or pool delete that has not yet committed makes a num_zones 2 create fail until it commits; the client can retry.
  • Resolved: replicated min_size on transitions (B26-B28).
    • A multi-zone pool (num_zones > 1), EC or replicated, keeps the min_size it was created with or last set to through the degraded, recovery and healthy transitions, as section 11.2 intends. That includes a pool created in degraded stretch mode.
    • Legacy stretch pools (num_zones 1: the pools of global stretch mode and individual stretch pools) still have min_size halved on the degraded transition and set to mon_stretch_pool_min_size on the healthy one, as on main.
  • Open question: the default min_size of a replicated multi-zone pool.
    • A --num-zones 2 pool with two replicas per zone gets min_size 2, the default for its size of 4 (B06). Before B27 the degraded transition lowered it to 1, as it still does for a global stretch mode pool, so one more OSD in the surviving zone could fail.
    • It now stays 2. In degraded stretch mode its PGs need both copies in the surviving zone, and I/O stops if either is lost.
    • Setting min_size 1 gives the old behaviour in every state, because while healthy the stretch peering rules still need a copy in each zone.
    • osd, mon: support per-zone replica min_size for stretch pools #35 derives the default from the replicas per zone, which gives 1, together with a per-zone check in the OSD. That default on its own would also let a num_zones 3 pool, which gets no stretch values, go active with one copy.
    • This series leaves the default as it is.
  • min_size on the OSD side. The design doc now gives min_size as in section 11.2.1, but OSDMap::stretch_ec_num_acting_below_min_size() applies min_size to each zone, which is section 11.2.2. Changing the OSD is a separate follow-up. test/osd: three-zone stretch EC unit tests #42 has a test that asserts the current behaviour. For a replicated multi-zone pool, the OSD counts min_size in the whole acting set, and the stretch peering rules choose the zones; B28 says so in section 11.3.
  • Overlaps with other stretchy-C PRs:
    • osd, mon: support per-zone replica min_size for stretch pools #35 (Kamoltat Sirivadhna, per-zone replica min_size, on an older stretchy-C) includes commits from mon: Support for setting num_zones via ceph osd pool set #15 and "mon: disallow EC Pool creation in global stretch mode". It touches the same areas as B13, B14 and B20 (multi-zone and EC pools in global stretch mode), B16, B27 and the min_size docs of B22 and B28. Its "osd, mon: support per-zone min_size for stretch pools" removes the min_size changes from both transitions for every replicated stretch pool, those of global stretch mode included, where B27 keeps them for num_zones 1 pools. The same commit derives a replicated multi-zone pool's default min_size from its replicas per zone (see the open question above). Expect conflicts in OSDMonitor.cc.
    • mon: Support for setting num_zones via ceph osd pool set #15 (Callum James, "Support for setting num_zones via ceph osd pool set") is the opposite of B16, which refuses osd pool set num_zones.
  • Commit structure:
    • B07 adds the global stretch mode refusal in prepare_pool_crush_rule(), and B15 rewords it.
    • B09 combines qa and doc changes and can be split if preferred.
    • B16, B20 and B25 cite the stretchy-C commits they follow up or correct by subject, since stretchy-C's shas change with each rebase.

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.

🤖 Generated with Claude Code

https://claude.ai/code/session_012ETDivFUQubLqznTDowHRu

aainscow and others added 30 commits October 5, 2026 23:42
…aying half size

Carried from ceph/ceph PR 72381 (branch
wip-stretch-degraded-pool-create); drop when stretchy-C is rebased onto
a main that has it.

A replicated pool created while the cluster is in degraded stretch mode
is given half the stretch pool size and a peering_crush_bucket_target
of 1. The return to healthy stretch mode restores only the bucket count
and min_size, so once the lost site is back the pool has size 2 and
min_size 2: the stretch rule puts both replicas in one zone, a bucket
count of 2 cannot be met, and every PG stays clean+peered.

Create a pool in degraded stretch mode, write to it, bring the site
back and expect the pool to match the other stretch pool and go clean.
This fails on the size check.

Fixes: https://tracker.ceph.com/issues/81390
Assisted-by: Claude Code
…raded stretch mode

Carried from ceph/ceph PR 72381 (branch
wip-stretch-degraded-pool-create); drop when stretchy-C is rebased onto
a main that has it.

Entering degraded stretch mode lowers each stretch pool's bucket count
to the surviving bucket count, sets the mandatory member and halves
min_size. Size and peering_crush_bucket_target are left alone, and
trigger_healthy_stretch_mode() undoes exactly those changes.

A pool created during degraded mode also had its size and bucket target
halved, which nothing restores. Apply only the changes the existing
pools get, so the healthy transition brings the new pool back to the
full stretch size with the others.

Fixes: https://tracker.ceph.com/issues/81390
Assisted-by: Claude Code
Carried from branch wip-mon-failed-pool-create, together with Jamie
Pryde's "mon: Roll back pending_inc on prepare_new_pool failure" from
ceph/ceph PR 71130, which follows unchanged; drop both when stretchy-C
is rebased onto a main that has them.

prepare_new_pool() adds the new pool to pending_inc before it has
finished checking the request. If a later check fails, for example a
crimson erasure pool whose profile does not support EC optimizations,
the pool stays in pending_inc without a name. The next proposal then
asserts in OSDMap::get_pool_name() from OSDMap::check_health():

  osd/OSDMap.h: 1437: FAILED ceph_assert(i != pool_name.end())

Assisted-by: Claude Code
Any error return in prepare_new_pool() after the new pool has been
inserted into pending_inc.new_pools and pending_inc.new_pool_max has
been incremented, but before pending_inc.new_pool_names is set, leaves
pending_inc in an inconsistent state: the pool ID is present in
new_pools but absent from new_pool_names.

On the next encode_pending() call, apply_incremental() adds the unnamed
pool to tmp.pools but not to tmp.pool_name. check_health() then
iterates pools and calls get_pool_name() on the unnamed ID, hitting
ceph_assert(i != pool_name.end()) and crashing the monitor.

Fix with a make_scope_guard() that erases the pool from
pending_inc.new_pools and decrements pending_inc.new_pool_max on
scope exit. The guard is dismissed once new_pool_names is set, so any
error return between pool allocation and name assignment automatically
triggers rollback without requiring explicit cleanup at each site.

Fixes: https://tracker.ceph.com/issues/79574
Signed-off-by: Jamie Pryde <[email protected]>
Assisted-by: IBM Bob 2.0.2
Carried from ceph/ceph PR 72378 (branch wip-monc-ping-uaf); drop when
stretchy-C is rebased onto a main that has it.

ping_monitor() deletes its temporary messenger while its ConnectionRef
is still in scope, so the last reference goes when the function returns
and ~AsyncConnection then reads async_msgr->cct from the freed messenger.
With cephx, "ceph ping mon.X" segfaulted in 164 of 180 attempts on a
vstart cluster:

  SubsystemMap::should_gather
  AsyncConnection::~AsyncConnection
  MonClient::ping_monitor
  librados::RadosClient::ping_monitor

Release the connection before shutting the messenger down. After this,
180 pings had no crashes.

Fixes: https://tracker.ceph.com/issues/81400
Assisted-by: Claude Code
Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main;
drop when stretchy-C is rebased onto a main that has it.

run_mon always runs ceph-mon --mkfs before it starts the daemon, so a
test that kills a monitor and starts it again on its existing data has
to repeat the arguments run_mon gives ceph-mon.

Move the command that starts the daemon into activate_mon, as
activate_osd does for OSDs, and call it from run_mon after --mkfs.
test_activate_mon restarts a monitor with an extra option.

Assisted-by: Claude Code
Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main;
drop when stretchy-C is rebased onto a main that has it.

Stretch mode on main supports replicated pools only: enable_stretch_mode
refuses a cluster with erasure coded pools, and pool creation refuses
them once stretch mode is on. 'ceph osd pool stretch set' does not check
the pool type, so it turns an erasure coded pool into a stretch pool,
and 'ceph osd pool stretch unset' then applies whatever size it is
given, for example size 6 to a k=2 m=1 pool.

Add mon-stretch-commands.sh for the stretch pool and stretch mode
commands, with a test on 3 mons and no OSDs that expects stretch set on
an EC pool to fail and the pool's size and min_size to stay as created,
and a replicated pool as the control. Only stretch set is checked: with
a fixed monitor no EC pool can be made a stretch pool, so the size check
of stretch unset cannot be set up, and the test only expects unset to
find no stretch pool.
TEST_stretch_set_ec_pool fails on the current code.

Fixes: https://tracker.ceph.com/issues/81427
Assisted-by: Claude Code
Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main;
drop when stretchy-C is rebased onto a main that has it.

Stretch mode on main supports replicated pools only, but 'ceph osd pool
stretch set' accepted an erasure coded pool, and 'ceph osd pool stretch
unset' then applied any size to it (a k=2 m=1 pool became size 6).

stretch set now refuses an erasure coded pool with -EINVAL, worded as
enable_stretch_mode words the same refusal.

stretch unset can then only meet an erasure coded pool that an older
mon stretched. Refusing it outright would leave no way to clear the
stretch values, so it accepts such a pool only with size k+m and
min_size between k and k+m, which also repairs a size the old stretch
set changed, and refuses anything else with -EINVAL.

Fixes: https://tracker.ceph.com/issues/81427
Assisted-by: Claude Code
Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main;
drop when stretchy-C is rebased onto a main that has it.

Say in doc/rados that 'ceph osd pool stretch set' refuses erasure-coded
pools, and what 'ceph osd pool stretch unset' needs to clear an
erasure-coded pool that an older release made a stretch pool.

The EC stretch cluster design said that stretch set works for any pool
type and that stretch unset needs no EC-specific changes. Say that
stretch set refuses EC pools and which EC pools stretch unset accepts,
and that allowing EC pools with zones > 1 must relax that refusal and
let the unset size check allow zones x (K+M).

Fixes: https://tracker.ceph.com/issues/81427
Assisted-by: Claude Code
…ch mode

Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main;
drop when stretchy-C is rebased onto a main that has it.

'ceph osd pool stretch set' and 'ceph osd pool stretch unset' configure
an individual stretch pool, which doc/rados/operations/stretch-mode.rst
offers as the alternative to stretch mode. Stretch mode manages the
pools' stretch values itself: enable_stretch_mode sets them, and the
degraded and healthy transitions change them. The monitor nevertheless
accepts both commands while stretch mode is enabled. For example, stretch
set run in degraded stretch mode gives the pool the healthy bucket count,
so its PGs stay peered until the lost zone returns.

Add a test to mon-stretch-commands.sh that enables stretch mode with 3
mons and 4 OSDs in two zones and expects stretch set and stretch unset
to fail and to leave the pool's bucket count, crush rule and size alone.
Stretch set succeeds on the current code.

Fixes: https://tracker.ceph.com/issues/81428
Assisted-by: Claude Code
…abled

Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main;
drop when stretchy-C is rebased onto a main that has it.

'ceph osd pool stretch set' and 'ceph osd pool stretch unset' configure
an individual stretch pool, the alternative to stretch mode, but the
monitor accepted both while stretch mode was enabled. Stretch mode sets
the pools' stretch values itself and changes them in its degraded and
healthy transitions, and a pool changed by hand does not follow them:
stretch set in degraded stretch mode gave the pool the healthy bucket
count, so its PGs stayed peered until the lost zone returned.

Refuse both commands with -EINVAL while stretch mode is enabled.

Fixes: https://tracker.ceph.com/issues/81428
Assisted-by: Claude Code
Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main;
drop when stretchy-C is rebased onto a main that has it.

Say in doc/rados that 'ceph osd pool stretch set' and 'ceph osd pool
stretch unset', which configure individual stretch pools, fail while
stretch mode is enabled.

Say the same in the EC stretch cluster design, and that allowing EC
pools with zones > 1 must relax this refusal as well.

Fixes: https://tracker.ceph.com/issues/81428
Assisted-by: Claude Code
…iming to act when it cannot

Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main;
drop when stretchy-C is rebased onto a main that has it.

'ceph osd force_healthy_stretch_mode' only ends recovery stretch mode,
but in healthy or degraded stretch mode it does nothing and still
replies "Triggering healthy stretch mode" with success, so an operator
who runs it before the cluster is recovering believes it took effect.

Add a test to mon-stretch-commands.sh that expects the command to fail
in healthy and in degraded stretch mode, and to return the cluster to
healthy stretch mode once it is recovering. Zone pze is lost by killing
its mon and OSDs and restored by starting them again with activate_mon
and activate_osd. The command succeeds in healthy stretch mode on the
current code.

Fixes: https://tracker.ceph.com/issues/81429
Assisted-by: Claude Code
…tch mode

Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main;
drop when stretchy-C is rebased onto a main that has it.

'ceph osd force_healthy_stretch_mode' only ends recovery stretch mode.
In healthy or degraded stretch mode, or without stretch mode, it did
nothing and still replied "Triggering healthy stretch mode" with
success.

Refuse it with -EINVAL and say that the cluster is not in recovery
stretch mode, before asking for --yes-i-really-mean-it.
force_recovery_stretch_mode has no such check to follow.

Fixes: https://tracker.ceph.com/issues/81429
Assisted-by: Claude Code
Carried from branch wip-mon-stretch-command-fixes for ceph/ceph main;
drop when stretchy-C is rebased onto a main that has it.

Say that 'ceph osd force_healthy_stretch_mode' fails unless the cluster
is in recovery mode.

Fixes: https://tracker.ceph.com/issues/81429
Assisted-by: Claude Code
ceph-mon no longer accepts --auth-supported, so every test in
crush-stretch.sh failed at the first run_mon. Use the same options as
the other standalone tests (875eab6).

Assisted-by: Claude Code
create_ec_pool_pp() built its two-zone test pool from a named profile
with a single-zone CRUSH rule, set num_zones afterwards through a raw
'osd pool set' and then gave the pool its stretch values with 'osd pool
stretch set'. Stretch set refuses an erasure coded pool since
"mon/OSDMonitor: refuse to stretch an erasure coded pool", carried
above, and a later commit in this series refuses the raw 'osd pool set
num_zones'.

A multi-zone EC pool is created from k and m with num_zones, which
builds a two-zone CRUSH rule and puts the pool in stretch mode. Create
the test pool with one 'osd pool create' carrying k, m, num_zones 2 and
the OSD failure domain the old profile used. RadosTestECPP creates this
pool only when the cluster has a two-zone topology.

Assisted-by: Claude Code
Add mon-stretch-helpers.sh, which the mon-stretch tests that follow
source, so that each stretch fix's test can live in its own script:

- run_stretch_tests runs the TEST_ functions given, or all of them,
  with a fresh cluster each;
- wait_for_stretch_state waits for the OSDMap's degraded and
  recovering stretch mode values, and pool_field reads a field of a
  pool;
- two_zone_cluster starts monitors a in dc1, b in dc2 and c as the
  arbiter, a manager, and a given number of OSDs (default 3) in each
  of dc1 and dc2, on a host each;
- ec_stretch_cluster_without_dc2 adds a 2-zone EC pool to that cluster
  and takes dc2's monitor and OSDs down, leaving degraded stretch mode;
- enable_global_stretch_mode enables global stretch mode ('ceph mon
  enable_stretch_mode') over the datacenters, with a pool on a stretch
  rule.

Assisted-by: Claude Code
…tch mode

A replicated pool created in degraded stretch mode keeps its size and
bucket target and gets the degraded bucket count and halved min_size
that the existing stretch pools have, so the healthy transition
restores it with them, as "mon/OSDMonitor: keep size and bucket target
for a pool created in degraded stretch mode" (carried above) does.
Say so in section 11.4.3.

The stretch mode transitions never change peering_crush_bucket_target;
only the bucket count and the mandatory member change. Correct the
degraded and recovery rows of the EC example table in section 11.6 and
its bucket_max note.

Assisted-by: Claude Code
…created

Creating a pool with --num-zones 2 configures it through
try_enable_stretch_mode(), which also wrote the cluster's stretch state
and set degraded_stretch_mode to 0. With a zone down this ended
degraded mode without the healthy transition: the other stretch pools
kept a bucket count of 1 and the surviving zone as mandatory member,
and the lost zone's monitor stayed in stretch_marked_down_mons, so it
could never lead. If the other zone then failed, the remaining monitor
and the tiebreaker could not form a quorum.

Write the cluster's stretch state only when stretch mode is not already
enabled. A pool joining a degraded stretch mode gets the degraded
bucket count and the surviving mandatory member that the other pools
have, so it can go active on the surviving zone and is restored with
them. Section 11.4.2 of the design says that a 2-zone pool created
while stretch mode is enabled configures only the new pool.

TEST_ec_pool_create_in_degraded_stretch_mode in
mon-stretch-ec-pool-create-degraded.sh creates a second stretch EC pool
with one zone down, checks that the cluster stays in degraded mode,
brings the zone back, and checks that both pools are fully stretched
again and that losing the other zone still leaves a quorum. Without the
fix it fails at the first check.

Assisted-by: Claude Code
'osd pool create <pool> --num-zones 2' builds a stretch rule that takes
num_replica_per_zone (default 2) hosts in each zone, but
prepare_pool_size() ignored num_zones for a replicated pool created
without a size, so the pool got osd_pool_default_size (3) and one zone
held a single replica.

Use num_zones * num_replica_per_zone, and the matching default
min_size. Global stretch mode keeps mon_stretch_pool_size. Section
2.1.3 of the design says so.

TEST_pool_create_stretch_replica in crush-stretch.sh now expects size 4
and min_size 2 for a 2-zone pool; without the fix the pool gets size 3.

Assisted-by: Claude Code
…etch mode

On main, 'osd pool create' without a rule in stretch mode uses the
stretch rule of the existing stretch pools. Here
prepare_pool_crush_rule() created a new rule for the pool from
num_zones, which defaults to 1, so the pool's copies were not split
between the sites.

Use the stretch rule of the existing stretch pools, as main does, and
create a rule for the pool only when num_zones asks for more than one
zone. Such a pool takes the cluster's rule, so --root,
--zone_failure_domain, --osd_failure_domain and --class would have no
effect. Refuse them instead of ignoring them, as is already done for an
EC pool created without k and m: global stretch mode is the legacy
stretch mode and does not take the new placement options. Section 2.1.4
of the design describes this.

TEST_stretch_mode_pool_create_without_rule in
mon-stretch-pool-create-global-rule.sh enables global stretch mode,
expects a pool created without a rule to get the stretch rule, and
expects a create with any of the placement options to be refused.
Without the fix the pool gets a single-zone rule and the options are
accepted.

Assisted-by: Claude Code
…d every check

prepare_new_pool() committed monitor stretch mode before it validated
the pool's stretch settings. When that validation failed, for example
because the two datacenters differ in weight, or when a later check
failed, such as FastEC support for a multi-zone erasure pool, the
create failed but the monitors stayed in stretch mode with a tiebreaker
and connectivity elections.

Validate the monitor and pool stretch settings where they were, but
apply them at the end of prepare_new_pool(), after the remaining
checks. A failed create no longer leaves the monitors or the OSDMap in
stretch mode.

TEST_failed_stretch_pool_create_leaves_mons in
mon-stretch-failed-create-mons.sh makes a 2-zone EC create fail on the
weight check and expects the monitors to stay out of stretch mode; it
fails without the fix. TEST_failed_stretch_pool_create_leaves_no_pool
in mon-stretch-failed-pool-create.sh covers the pool side of a failed
stretch create: a --num-zones 2 replicated create that fails because
stretch mode cannot be enabled for the monitors, after
prepare_new_pool() has allocated the pool, must leave the next pool
create working. That relies on "mon: Roll back pending_inc on
prepare_new_pool failure", carried above.

Assisted-by: Claude Code
An erasure code profile is created either with 'osd erasure-code-profile
set' or by 'osd pool create' with k and m, and it is deleted with the
last pool that uses it, as main already deletes an erasure pool's CRUSH
rule.

Describe this in the profile and pool user docs, with a note for
scripts that reuse a profile after deleting its pools. Add section
2.1.5 to the design: how a pool gets its profile (generated from k and
m, named, or default), the generated profile's name and contents, the
parameter combinations the monitor refuses, how the profile sets the
pool's size, shard counts and CRUSH rule, what multi-zone pools need,
that num_zones is a pool option and not a profile key, and when a
profile is deleted. Correct the design passages that said stretch EC
pools do not use profiles and that num_zones would be changed by
swapping profiles.

Two qa users reused a profile after deleting its last pool.
TEST_erasure_pool_crush_rule_rm in osd-crush.sh now checks that the
profile went with the pool and sets it again. The rados task set up its
profile and CRUSH rule once and then created and deleted pools in every
run, so a second run created its pools with a profile that no longer
existed; it now sets them up at the start of every run.

Assisted-by: Claude Code
The stretch pool parameters (num_zones, root, zone_failure_domain,
osd_failure_domain, num_replica_per_zone, class) were inserted after
"rule" in the osd pool create command description, so a legacy
positional create such as

  ceph osd pool create p 8 8 erasure default erasure-code 1000

passed 1000 as num_zones instead of expected_num_objects and failed
with "erasure_code_profile cannot be used with multi-zone
configurations". The design keeps the legacy positional syntax and adds
no positional arguments.

Restore main's order for the existing parameters and list the ones
added for stretch pools (num_zones, root, zone_failure_domain,
osd_failure_domain, num_replica_per_zone, class, k and m) after "--",
so they can only be given by name.

TEST_legacy_positional_pool_create in
mon-stretch-pool-create-positional.sh expects the legacy erasure and
replicated forms to set expected_num_objects; without the fix the
erasure one fails.

Assisted-by: Claude Code
'osd pool create <pool> erasure --num_zones 2' without --k/--m and
without a profile was accepted. The pool took the default profile, and
the shared erasure-code rule was built for it as a two-datacenter
stretch rule, which the next plain 'osd pool create <pool> erasure'
then also used, placing a single-zone pool in one datacenter. The
design creates multi-zone EC pools from k and m, never from an existing
profile.

Refuse such a create with -EINVAL, as an explicit profile with
num_zones > 1 already is, and list the refusal with the other parameter
combinations in section 2.1.5 of the design.
TEST_multi_zone_ec_pool_requires_k_m in
mon-stretch-pool-create-multi-zone-km.sh expects the refusal; without
the fix the pool is created.

Assisted-by: Claude Code
…xist

'ceph osd pool stretch set' and 'unset' configure individual stretch
pools, while a pool with num_zones > 1 takes its size and stretch
values from num_zones at creation. Both commands are refused while the
OSDMap has stretch mode enabled ("mon/OSDMonitor: refuse stretch set
and unset while stretch mode is enabled", carried above), which covers
the stretch mode a num_zones 2 pool create enables. A pool with
num_zones > 2 enables no stretch mode, and the commands still changed
any pool, the multi-zone pool included, while one existed.

Also refuse both commands with -EINVAL while any pool, committed or
pending, has num_zones > 1, and check global stretch mode in the
monitor map together with the OSDMap's stretch mode.
refuse_in_stretch_mode() becomes an OSDMonitor member. find_pool()
finds the first committed or pending pool that a predicate accepts,
and find_multi_zone_pool() uses it to find a pool with num_zones > 1.
With global stretch mode refused, stretch set no longer reaches the
validation of the new CRUSH rule it ran in global stretch mode; remove
it.

Section 11.4.1 of the design planned EC validation for stretch set.
Stretch set is not part of the stretch EC design: a multi-zone pool
takes its stretch values from num_zones at creation. Say in 11.4.1 and
story 4a of section 14 that stretch set refuses erasure coded pools,
and that stretch set and unset are refused while stretch mode is
enabled, global or started by a num_zones 2 pool create, and while any
pool has num_zones > 1. Add the last refusal to section 2.1.5, and say
the same in doc/rados. stretch-mode.rst also said that stretch unset
disables stretch mode for individual pools, which is not possible while
stretch mode is enabled.

mon-stretch-multi-zone-stretch-set.sh has two tests.
TEST_stretch_pool_commands_with_two_zone_pools creates a 2-zone
replicated and a 2-zone EC pool and expects stretch set and unset to
fail for both and for an ordinary replicated pool, leaving their
stretch values and size alone.
TEST_stretch_pool_commands_with_three_zone_pool expects the same with
a 3-zone replicated pool, which enables no stretch mode, and expects
stretch set to work once the 3-zone pool is deleted; without the fix
stretch set is accepted for the replicated pool while the 3-zone pool
exists.

Assisted-by: Claude Code
Global stretch mode ('ceph mon enable_stretch_mode') is the legacy
stretch mode and keeps its earlier behaviour, while a pool with
num_zones > 1 sets up its own stretch mode. 'osd pool create' accepted
num_zones > 1 in global stretch mode: a replicated pool was created,
and an EC pool was refused only after its generated profile had been
created, which stayed behind.

Refuse num_zones > 1 with -EINVAL while global stretch mode is enabled
or being enabled, before anything is created. prepare_new_pool() then
no longer sees a multi-zone pool in global stretch mode, so drop the
rule validation it ran for one. As stretch set is refused in stretch
mode too, validate_stretch_mode_new_pool() has no caller left: remove
it, extract_sites_from_crush_rule(), which only it used, and its unit
tests (OSDMonitorValidateStretchModeNewPoolTest). Sections 2.1.3, 2.1.4
and 11.4.2 of the design say so; the note that a pool created after
enable_stretch_mode does not get the mandatory member now applies only
to the legacy pools of global stretch mode.

TEST_multi_zone_pool_create_in_global_stretch_mode in
mon-stretch-global-mode-multi-zone.sh enables global stretch mode and
expects replicated and EC creates with num_zones 2 to be refused,
leaving no pool, CRUSH rule or profile; without the fix the replicated
pool is created.

crush-stretch.sh created multi-zone pools in global stretch mode in
three tests. TEST_stretch_diff_sites and
TEST_stretch_diff_bucket_barrier did so only to see the pool refused
for a CRUSH rule over other datacenters or over another bucket type
than stretch mode's, which nothing reaches any more.
TEST_stretch_diff_sites goes, and TEST_stretch_diff_bucket_barrier
keeps only enabling stretch mode over zone buckets with a device class
rule. TEST_stretch_replica_device_class_pools creates its pools without
num_zones.

Assisted-by: Claude Code
'ceph mon enable_stretch_mode' takes every pool into global stretch
mode, the legacy stretch mode, which manages it as a legacy stretch
pool: it sets size and min_size from mon_stretch_pool_size and
mon_stretch_pool_min_size, and disable_stretch_mode resets the pool to
the default size and rule. A pool with num_zones > 1 has its own
stretch values and keeps them in step itself, yet enable_stretch_mode
succeeded with one present.

Refuse enable_stretch_mode with -EINVAL while any pool, committed or
pending, has num_zones > 1, before anything is changed. The pool is
found with find_multi_zone_pool(), as for stretch set and unset.

Section 11.4.2 of the design planned for enable_stretch_mode to accept
multi-zone EC pools and set their stretch values, and story 4b of
section 14 still planned it. A multi-zone pool gets its stretch values
when it is created; describe the refusal instead. min_size stays as
created and is interpreted as in section 11.2.1 rather than set to
r(k+m)-m.

TEST_enable_stretch_mode_with_multi_zone_pool in
mon-stretch-global-mode-multi-zone.sh creates a 2-zone replicated pool
and expects enable_stretch_mode to be refused, even with the pool's own
rule, and global stretch mode to stay off; without the fix it is
enabled.

Assisted-by: Claude Code
… pool

A replicated pool created without a rule and with num_zones 1 uses the
default replicated rule outside global stretch mode, so --root,
--zone_failure_domain, --osd_failure_domain and --class were accepted
and ignored. Refuse them with -EINVAL, as global stretch mode already
does for its pools, which use the stretch rule. Multi-zone pools and EC
pools, whose rule is built from these options, are not affected.

The global stretch mode refusal said the options "cannot be used
without num_zones in stretch mode", which suggests giving num_zones,
and num_zones > 1 is refused in global stretch mode. Point at --rule
instead. Sections 2.1.4 and 2.1.5 of the design quote both refusals.

TEST_single_zone_replicated_placement_options in
mon-stretch-replicated-placement-options.sh expects each option to be
refused, with and without --num-zones 1, and no pool to be created;
without the fix the pool is created.
TEST_stretch_mode_pool_create_without_rule in
mon-stretch-pool-create-global-rule.sh expects the new global stretch
mode wording.

Assisted-by: Claude Code
MonMap::encode() for umbrella peers writes a version 10 header, but it
still appends global_stretch_mode_enabled, a version 11 field.
MonMap::decode() reads that field only from version 11, and for older
versions sets it to stretch_mode_enabled. So a monmap with stretch mode
enabled and global stretch mode disabled, as a num_zones 2 pool create
leaves it, decodes with global stretch mode enabled.

Add two unittest_mon_monmap tests. Each sets stretch_mode_enabled,
encodes the monmap with CEPH_FEATURES_ALL, which includes
SERVER_UMBRELLA, and decodes it. global_stretch_mode_enabled must come
back as it was set: false in umbrella_stretch_mode_without_global, true
in umbrella_global_stretch_mode.
MonMapEncode.umbrella_stretch_mode_without_global fails on the current
code.

Assisted-by: Claude Code
"mon/MonMap: Return early from encoding if before umbrella" gave
pre-umbrella peers a version 9 encoding of their own, and changed the
version of the umbrella encoding from 11 to 10. That encoding still
ends with global_stretch_mode_enabled, a version 11 field.
MonMap::decode() reads the field only when struct_v >= 11. For a
version 10 struct it sets global_stretch_mode_enabled to
stretch_mode_enabled.

So once a num_zones 2 pool create enables stretch mode, every monitor
decodes the committed monmap with global stretch mode enabled too.
Later num_zones > 1 creates are then refused as if 'ceph mon
enable_stretch_mode' had been run. So is the create that enabled
stretch mode, when it is resent after the election that enabling
stretch mode starts. These standalone tests fail:
- crush/crush-stretch.sh: TEST_pool_create_stretch_ec and
  TEST_pool_create_stretch_replica
- mon-stretch/mon-stretch-multi-zone-stretch-set.sh:
  TEST_multi_zone_pool_create_with_stretch_pool and
  TEST_stretch_pool_commands_with_two_zone_pools

Encode the umbrella monmap as version 11 again, as before that commit.
compat_v stays 6, so a decoder that knows only version 10 still accepts
it and skips the last field.

This can be squashed into "mon/MonMap: Return early from encoding if
before umbrella".

Assisted-by: Claude Code
… multi-zone pool's min_size

The degraded stretch mode transition halves the min_size of every
replicated pool with stretch values, and the healthy transition sets it
to mon_stretch_pool_min_size. That includes replicated pools created
with --num-zones 2. Section 11.2 of the design gives the min_size of a
multi-zone pool for one zone and interprets it for the stretch mode
state instead, so the transitions should leave it alone.

TEST_multi_zone_replicated_min_size in the new
mon-stretch-multi-zone-min-size.sh creates two replicated --num-zones 2
pools, one with the default min_size (2) and one with min_size 1
(osd_pool_default_min_size 1, as vstart.sh sets it). It loses dc2,
creates a third pool with min_size 1 in degraded stretch mode, and
brings dc2 back. It checks that each pool keeps its min_size in
degraded and in healthy stretch mode. It fails at the first check in
degraded stretch mode, where the default pool has min_size 1 and the
min_size 1 pool has min_size 0. After the healthy transition all three
pools have min_size 2.

TEST_global_stretch_mode_min_size checks that a pool in global stretch
mode, the legacy stretch mode, still has its min_size halved on the
degraded transition and set to mon_stretch_pool_min_size on the healthy
one, as on main. It passes.

lose_dc2 and restore_dc2 move the zone loss and return of
mon-stretch-ec-pool-create-degraded.sh into mon-stretch-helpers.sh.

Assisted-by: Claude Code
…nsitions

trigger_degraded_stretch_mode() halved the min_size of every replicated
pool with stretch values, and trigger_healthy_stretch_mode() set it to
mon_stretch_pool_min_size (default 2). That included replicated pools
created with --num-zones 2. A pool created with min_size 1 got
min_size 0 in degraded stretch mode, which 'osd pool set' refuses, and
min_size 2 once the cluster was healthy again. From then on its PGs
needed two copies instead of the one it was created with. A pool
created in degraded stretch mode kept its min_size only until the
healthy transition.

Section 11.2 of the design gives the min_size of a multi-zone pool,
EC or replicated, for one zone, and does not change it on transitions.
The transitions already leave EC pools alone.

Leave the min_size of pools with num_zones > 1 alone on both
transitions. Legacy stretch pools, with num_zones 1, are those of
global stretch mode and individual stretch pools. Their min_size is
still halved on the degraded transition and set to
mon_stretch_pool_min_size on the healthy one, as on main. The pool
create path that halves min_size in degraded stretch mode is taken
only in global stretch mode, which refuses multi-zone pools, so it is
unchanged.

Only for an EC pool does the OSD count min_size per zone. A replicated
PG needs min_size copies in its acting set, and the stretch peering
rules take them from both zones while healthy and from the surviving
zone while degraded. A --num-zones 2 pool with two replicas per zone
gets the default min_size for its size of 4, which is 2. The degraded
transition used to lower that to 1. It now stays 2, so in degraded
stretch mode its PGs need both copies in the surviving zone. With
min_size 1 such a pool behaves in every stretch mode state as the
default pool did before.

TEST_multi_zone_replicated_min_size passes now.

Assisted-by: Claude Code
Sections 11.3, 11.4.3 and 11.4.4 of the design said that the monitor
halves the min_size of every replicated stretch pool, num_zones 2 pools
included, on the degraded transition and sets it to
mon_stretch_pool_min_size on the healthy one, and recorded that as a
difference from the intent of section 11.2. The monitor now leaves the
min_size of every multi-zone pool alone. Say so there, and that only
legacy replicated stretch pools, with num_zones 1, still have their
min_size changed, as on main. Say in 11.3 that the OSD counts min_size
per zone only for EC pools, and what a replicated multi-zone PG needs
instead. Say in 11.4.2 that a pool created in degraded stretch mode
keeps its min_size.

stretch-mode.rst said that the loss of a data center reduces the
min_size of all pools to 1. Say that this is for the pools in global
stretch mode, that the loss and return of a zone do not change the
min_size of a pool created with --num-zones, and that while a zone is
down its PGs need min_size copies or shards in the surviving zone.

Assisted-by: Claude Code
* Remove the need for an EC profile. Indeed, stretch mode EC pools will be mutually
exclusive with the use of a profile.
* Remove the need to create an EC profile before the pool: ``--k`` and ``--m`` generate one
for the pool (Section 2.1.5). A multi-zone EC pool cannot be created from an existing

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is inaccurate since we are allowing num_zones with EC profile.

@@ -252,7 +253,8 @@ These parameters are intended for advanced users and offer finer control over th
**--erasure_code_profile**
- *Definition*: The legacy EC Profile to use.
- *Note*: Mutually exclusive with ``--num_zones``: Cannot be used with multi-zone configurations. Also

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer true.

* ``--erasure_code_profile`` with ``--k`` and ``--m``: "cannot specify both
erasure_code_profile and k/m parameters".
* Only one of ``--k`` and ``--m``: "erasure_code_profile requires both k and m".
* ``--erasure_code_profile`` (any name, ``default`` included) with ``--num_zones`` greater

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not valid

* ``--erasure_code_profile`` (any name, ``default`` included) with ``--num_zones`` greater
than 1: "erasure_code_profile cannot be used with multi-zone configurations".
``--num_zones 1`` is accepted.
* ``--num_zones`` greater than 1 without ``--k`` and ``--m``: "multi-zone erasure coded

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? I would think we would want to allow a default "osd pool create foo erasure --num-zones 2"

Comment thread src/mon/OSDMonitor.cc
}
string name;
int num_zones = 0;
if (find_multi_zone_pool(&name, &num_zones)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calls this due to num_zones > 2 not enabling stretch mode but num_zones > 2 is not supported anyways. Safe to keep still.

``num_zones`` is stored as a pool option, set on every pool at creation (default 1), and not in
the profile. ``ceph osd pool get <pool> num_zones`` shows it. It cannot be changed after
creation; changing the number of zones of an existing pool is a later release (Section 13.2).
``ceph osd pool set`` does not offer ``num_zones``, and the monitor refuses it with EINVAL also

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong since changing num_zones is supported.

block of ``k+m`` shards (Section 11.2).
* ``min_size`` to ``k + min(1, m-1)``, not scaled by ``num_zones``. ``min_size`` is given for
one zone and interpreted as in Section 11.2.1: in healthy stretch mode a PG needs
``min_size + k + m`` shards in total, and in degraded stretch mode ``min_size`` shards in the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong it needs min_size (k) shards per zone.

* - **Healthy**
- ``num_zones × (K+M) − M``
- Full redundancy; tolerate up to M failures
- ``min_size + K + M`` in total

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least min_size shards per zone

* - **Healthy** (resync complete)
- ``num_zones × (K+M) − M``
- Full min_size restored
- ``min_size + K + M`` in total

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min_size shards per zone

- The acting set includes at least K shards in at least one surviving zone
- In healthy mode, all zones have ``K+M`` shards
- In healthy mode, the acting set has at least
``min_size + (num_zones − 1) × (K + M)`` shards across all zones

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min_size * num_zones across all zones

- **Rule: if a zone fails, reduce min_size by K+M. If a zone becomes
healthy again, increase min_size by K+M.**
A zone failure does not change ``min_size``; it changes where the shards are
counted (Section 11.2.1). The number of shards a PG needs falls by ``K+M``

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not valid

@kamoltat kamoltat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think some of the stuff in this commit overlaps with #35

Comment on lines +201 to +204
- *Pool Size*: For an EC pool, the resulting pool ``size`` is ``num_zones × (k + m)``. For a
replicated pool created with ``num_zones`` greater than 1 and without ``--size``, it is
``num_zones × num_replica_per_zone`` (4 for 2 zones of 2 replicas). In global stretch mode
(``ceph mon enable_stretch_mode``) a replicated pool's size is ``mon_stretch_pool_size``.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#35
will introduce --replica. For replicated pool size = num_zones x replica

@aainscow

aainscow commented Oct 8, 2026

Copy link
Copy Markdown
Owner Author

Closing. This PR was split into smaller PRs, each reviewed and merged into stretchy-C:

The rest was not carried forward:

@aainscow aainscow closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core documentation Improvements or additions to documentation mon tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants