Skip to content

mon: Support for setting num_zones via ceph osd pool set - #15

Closed
CJamesIBM wants to merge 118 commits into
aainscow:stretchy-Cfrom
CJamesIBM:stretch_ec_cal_wip
Closed

CJamesIBM wants to merge 118 commits into
aainscow:stretchy-Cfrom
CJamesIBM:stretch_ec_cal_wip

Conversation

@CJamesIBM

@CJamesIBM CJamesIBM commented Jul 2, 2026 •

Copy link
Copy Markdown
Collaborator

Adds support for moving individual pools between single-zone and two-zone stretch mode via 'ceph osd pool set num_zones <1|2>. This works for both replica and erasure coded pools.

When moving to 2 zones the monitor validates and commits all required stretch mode state changes including pool size, CRUSH rules and monmap + OSD stretch mode.

When moving to a single zone, stretch mode params are cleared, CRUSH rules are cleaned up, and if it is the last stretch pool in the cluster, cluster level stretch mode is fully torn down.

NOTES

  • Replica pool size and min_size currently read from ceph config
  • Currently hardcodes zone and osd failure domain
  • Documentation needs to be added
  • Some code such as verifying and enabling mon + OSD stretch mode and tearing down cluster stretch mode is mirrored from pool create and pool delete and can probably needs to be abstracted to function

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.

Comment thread src/mon/OSDMonitor.cc Outdated
unsigned size = 0;
unsigned min_size = 0;
if (p->is_replicated()) {
size = g_conf().get_val<uint64_t>("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.

This is not ideal when increasing num_zones to 2 and certainly won't work when we support 3 zones as well. I'd like to try and get rid of using mon_stretch_pool_size except when enabling global stretch mode and when creating a replica pool with num_zones > 1.

Where I'd like to eventually get to is a calculation like this that can be used regardless of what num_zones is changed to:

replicas_per_zone = (old_size / old_num_zones)
size = replicas_per_zone * new_num_zones
min_size remains unchanged

This means the number of replica's per zone stays the same and we just scale size according to the number of zones. The min size will eventually be between 1 and number of replica's per zone

Currently we haven't made changes to how min_size is interpreted so we should probably set it like this for now:

min_size += replicas_per_zone * (new_num_zones - old_num_zones)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in new commit

Comment thread src/test/librados/ec_pool_create_cxx.cc Outdated

const std::string pool_name = get_temp_pool_name("repl_set_num_zones_");
std::string cmd = "{\"prefix\": \"osd pool create\", \"pool\": \"" +
pool_name + "\", \"pool_type\": \"replicated\", \"pg_num\": 8}";

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.

Should test with replica pools with different numbers of replicas

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in new commit

Comment thread src/mon/OSDMonitor.cc Outdated

const string zone_failure_domain = "datacenter";

if (num_zones == 2) {

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.

nit: could future proof this with num_zones > 1

Question - should the enabling stretch and disabling stretch code be in separate functions, its a very long if statement...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

num_zones > 1 addressed in commit.

Code remains as 1 function for now but refactoring has made the function smaller

Comment thread src/mon/OSDMonitor.cc Outdated
unsigned size = 0;
unsigned min_size = 0;
if (p->is_replicated()) {
size = g_conf().get_val<uint64_t>("osd_pool_default_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.

See comment above, think you can make this code common with the increasing number of zones code path and make changing the number of zones work with replica pools with any number of replicas rather than using conf variables to decide how many replicas to have

I'd really like to make these conf variables only be used when creating a pool and not specifying a size, with one conf variable for when num_zones=1 and the other for when num_zones>1. If you create a pool with X replicas per zone then I think changing number of zones should preserve having X replicas per zone.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in commit

Comment thread src/mon/OSDMonitor.cc Resolved
Comment thread src/mon/OSDMonitor.cc Outdated
if (pid == skip_pool) {
continue;
}
if (auto it = pending_inc.new_pools.find(pid);

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.

nit: code structure is a bit messy, would be better to have const auto&pp set to either the osdmap.pool or the pending_inc.new_pools pool and then have a single if (pp.crush_rule == old_rule_id) check to avoid the duplicated if and the continue

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in commit

Comment thread src/mon/OSDMonitor.cc Resolved
Comment thread src/mon/OSDMonitor.cc Resolved
@CJamesIBM
CJamesIBM requested a review from bill-scales July 7, 2026 10:39
@CJamesIBM
CJamesIBM requested review from bill-scales and removed request for bill-scales August 19, 2026 15:45

@bill-scales bill-scales 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.

Changes look ok, but there is a question about what to do when increasing the number of zones. I think this might be overlapping with some of the changes that @kamoltat has been looking at - so lets get Junior to review it and work out how this fits with what he has been doing

Comment thread src/mon/OSDMonitor.cc
}

string root = "default";
string osd_failure_domain = "host";

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 the tricky bit - we are increasing num_zones to 2, we don't have all the parameters that we have on create pool so you are just assuming defaults for root, osd_failure_domain and zone_failure_domain.

I think Junior is looking at being able to pass some of these as extra parameters to the set pool command

@bill-scales
bill-scales requested a review from kamoltat August 21, 2026 17:15
@bill-scales

Copy link
Copy Markdown
Collaborator

@kamoltat can you review this - I think it might be overlapping with some of the changes you are making

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@Ericmzhang
Ericmzhang force-pushed the stretchy-C branch 2 times, most recently from eaaaa32 to 297e857 Compare September 22, 2026 21:53
Small unit tests built around MemStore (e.g. PGBackendTestFixture) had
to create a real directory on disk for every test run, just to satisfy
MemStore's assumption that it always persists its state to a path.

When MemStore is constructed with an empty path, skip all disk I/O:
- mount/umount skip _load()/_save()
- mkfs skips writing the collections file on disk
- write_meta/read_meta use an in-memory map (meta_map) instead of
  the on-disk ObjectStore::write_meta/read_meta implementation

Also update PGBackendTestFixture to exploit the new mode: pass an
empty path to MockStore so tests no longer create a temporary directory
on disk, removing the mkdir/cleanup_data_dir machinery entirely.

Assisted-by: Claude Sonnet 5 <[email protected]>
Assisted-by: IBM Bob v2.1.0
Signed-off-by: Alex Ainscow <[email protected]>
MockStore was header-only with no factory, requiring callers to
manually construct, mkfs and mount the store. A static create()
factory method has been added to encapsulate that initialisation
sequence and return a shared_ptr, keeping construction errors
contained in one place. The implementation is moved to a new
MockStore.cc to keep the header lean.

Assisted-by: IBM Bob v2.1.0
Assisted-by: Claude Code:Claude Opus 5/Claude Opus 4.8/Claude Sonnet 5
Signed-off-by: Alex Ainscow <[email protected]>
Unit and backend tests lacked a mechanism to track expected object data,
attributes, and omap state across transaction commits to verify data
consistency after peering and recovery scenarios.

Introduce ObjectTracker to record object modifications (data writes, creates,
attribute writes, and omap operations) and reconstruct the expected state for
verification in PG backend test fixtures.

Assisted-by: IBM Bob v2.1.0
Assisted-by: Claude Code:Claude Opus 5/Claude Opus 4.8/Claude Sonnet 5
Signed-off-by: Alex Ainscow <[email protected]>
Previously, pgtemp_primaryfirst tests only covered a limited set of shard
permutations without comprehensively validating shard-to-OSD mapping across
different EC configurations and edge cases like overlapping or out-of-range OSDs.

This adds a comprehensive test suite (pgtemp_primaryfirst_comprehensive)
exercising various combinations of (k, m, num_zones) and multiple OSD layout
patterns (large OSD IDs, overlapping OSDs, all-same OSDs) to ensure roundtrip
consistency between pgtemp_primaryfirst and pgtemp_undo_primaryfirst.

Assisted-by: IBM Bob v2.1.0
Assisted-by: Claude Code:Claude Opus 5/Claude Opus 4.8/Claude Sonnet 5
Signed-off-by: Alex Ainscow <[email protected]>
TestBackendBasics and TestCommon previously used a flat listeners/backends
map keyed by OSD instance, which broke when the fixture was extended to
support multi-zone EC pools (where pool size = num_zones * (k+m)).

Add num_zones to BackendConfig (default 1, preserving existing behaviour).
Update simulate_multiple_osd_failures to accept std::set<int> and iterate
via the osd_fixtures/pgs hierarchy instead of the old flat listeners map.
Add MultiZoneWriteThenRead and MultiZoneFailover tests that exercise write,
read and degraded-read paths for multi-zone configurations.
Clean up TruncateGrowWithSuspendedReads and RollbackInvalidateRealistic to
delete test objects before teardown to avoid false scrub failures against
stale ObjectTracker state.

Assisted-by: IBM Bob v2.1.0
Assisted-by: Claude Code:Claude Opus 5/Claude Opus 4.8/Claude Sonnet 5
Signed-off-by: Alex Ainscow <[email protected]>
…_pool()

Add pool_id and num_zones parameters to create_ec_pool(). A multi-zone
pool has size num_zones * (k + m) and min_size num_zones * (k + m) - m,
and the nonprimary shard pattern (shards 1..k-1) is repeated per zone.

FLAG_HASHPSPOOL is now always set so that pool_id is mixed into the
placement hash, and a comment explains why pg_num/pgp_num must be
non-zero (pgp_num == 0 collapses every PG seed to the same CRUSH hash).

Assisted-by: IBM Bob v2.1.0
Assisted-by: Claude Code:Claude Opus 5/Claude Opus 4.8/Claude Sonnet 5
Signed-off-by: Alex Ainscow <[email protected]>
Add helpers that later fixtures and tests use to reshape the OSDMap
between peering cycles:

- set_pool_min_size(): rewrite a pool's min_size in a new epoch.
- add_osd(): add an OSD to the map (exists, in, down) with default
  xinfo features and a CRUSH item name.
- set_pg_upmap_slot(): place an OSD at a given shard position of a PG
  via pg_upmap, extending the acting set with CRUSH_ITEM_NONE if needed.
- new_osd_up(): convenience wrapper combining add_osd(), mark_osd_up(),
  set_pg_upmap_slot() and CRUSH finalization.

Each helper has an OSDMap& and a shared_ptr<OSDMap> overload, matching
the existing helpers in this file.

Assisted-by: IBM Bob v2.1.0
Assisted-by: Claude Code:Claude Opus 5/Claude Opus 4.8/Claude Sonnet 5
Signed-off-by: Alex Ainscow <[email protected]>
Introduce two plain data containers that the OSD test fixtures will be
migrated onto:

- TestPG holds everything that is per-PG: its spg_t and pg_whoami, the
  ObjectStore collection (collections are keyed by spg_t, not by OSD),
  the optional peering components (ShardDpp, MockPeeringListener,
  PeeringState, PeeringCtx), the optional backend components
  (MockPGBackendListener, PGBackend), the per-PG OBC cache and the
  per-PG outstanding-writes counter.  Member order is chosen so that
  destruction order respects the raw pointers held between them.

- OsdTestFixture holds everything that is per-OSD: its own MockStore
  (and the on-disk data dir it removes on destruction), the EC extent
  cache LRU, and a map of spg_t -> TestPG so that one OSD can host
  several PGs.

Nothing uses these yet; subsequent commits move PGBackendTestFixture
and ECPeeringTestFixture onto them so that shard N no longer has to
live on OSD N.

Assisted-by: IBM Bob v2.1.0
Assisted-by: Claude Code:Claude Opus 5/Claude Opus 4.8/Claude Sonnet 5
Signed-off-by: Alex Ainscow <[email protected]>
Events now carry an optional TestPG* in addition to from/to OSD.  The
loop keeps a static current_test_pg that mirrors current_executing_osd:
it is cleared whenever the executing OSD changes and set from the event
when one is provided, so fixture code running inside an event can find
"the PG I am running as" via EventLoop::get_current_test_pg().

- schedule_transaction() captures the current TestPG at scheduling time
  (and asserts one is set).
- schedule_peering_event() gains an overload taking an explicit TestPG*;
  the old overload passes nullptr for MockPeeringListener, which owns
  its own ps/ctx and does not need the context.
- run_in_pg(osd, test_pg, fn) runs a callable with a given OSD/PG
  context and restores all three pieces of ambient state afterwards
  (including current_osd, so a later run_one() still clears the PG
  context when the OSD changes).

This is the mechanism that lets one OSD host multiple PGs: the PG a
callback belongs to is no longer derivable from the OSD number alone.

Assisted-by: IBM Bob v2.1.0
Assisted-by: Claude Code:Claude Opus 5/Claude Opus 4.8/Claude Sonnet 5
Signed-off-by: Alex Ainscow <[email protected]>
…age spg_t

Add a TestPGGetter callback (osd, spg_t) -> TestPG*.  When a message is
sent, MockMessenger extracts the spg_t from the encoded message (either
an MOSDFastDispatchOp or an MOSDPeeringOp), looks up the target TestPG
on the destination OSD, and sets it as the EventLoop's current TestPG
context when the delivery event runs.

This replaces the implicit assumption that OSD N only ever hosts shard
N of a single PG: after a split, or with real CRUSH placement, the
receiver must be identified by (osd, spg_t).

set_epoch_getter() now takes its argument by const reference, and the
stray trailing comment is dropped.

Assisted-by: IBM Bob v2.1.0
Assisted-by: Claude Code:Claude Opus 5/Claude Opus 4.8/Claude Sonnet 5
Signed-off-by: Alex Ainscow <[email protected]>
…ary_spg_t

Own a PGPool built from the OSDMap at construction, and serve get_pool()
from pool.info instead of looking the pool up in the OSDMap on every
call.  This matters because ECBackend's stripe_info_t keeps a pointer to
the pg_pool_t it was given: keeping a stable pool.info member (updated
in place via PGPool::update() when the OSDMap changes) keeps that
pointer valid across deepish_copy_from()'d OSDMaps.

primary_spg_t() now returns spg_t(info.pgid.pgid, primary_shard().shard)
rather than a default-constructed spg_t, so callers routing by spg_t
get the real primary.

Assisted-by: IBM Bob v2.1.0
Assisted-by: Claude Code:Claude Opus 5/Claude Opus 4.8/Claude Sonnet 5
Signed-off-by: Alex Ainscow <[email protected]>
Two independent defects in the previous commit's multi-zone test:

1. MultiZoneWriteThenRead's skip guard checked
   `backend_config.num_zones == 0`, which no EC row in kBackendConfigs
   ever sets, so the guard never fired and the test ran identically to
   plain WriteThenRead for every single-zone EC config. Change it to
   `num_zones <= 1`, matching the already-correct MultiZoneFailover
   guard just below it, so the test only runs for the one genuinely
   multi-zone (num_zones == 2) config it was written for.

2. The new EC_ISA_Opt_k4m2_zones2 row sat after the `#endif` that
   closes the `#ifdef WITH_EC_ISA_PLUGIN` block guarding every other
   isa-plugin row in kBackendConfigs, so a build with the ISA plugin
   disabled would still try to construct an ec_plugin="isa" config and
   fail to load it. Move the row inside the ifdef, alongside the other
   isa rows.

Built and ran:

    ninja unittest_backend_basics
    ./bin/unittest_backend_basics --gtest_filter=*MultiZoneWriteThenRead*

Now exits 0: 8 tests pass (the single zones=2 config x 8 sizes) and the
other 104 are skipped, with the previous commit's regression-canary
assertion in MultiZoneGuardCheckEnvironment::TearDown() no longer
tripping. Also ran the full unittest_backend_basics binary (no filter):
1258 tests, exit 0.

Assisted-by: Claude Sonnet 5 <[email protected]>
Some peering tests' docstrings claim they scrub or recover at a specific
point in their body, but nothing in the body actually verifies that a
call happened - so a missing call silently passes. Add per-fixture-instance
counters, incremented inside scrub_object() and run_parallel_recovery()
(which run_recovery() delegates to), so a test can assert it actually
invoked one of these helpers at a given point, distinct from the
unconditional consistency scrub PGBackendTestFixture::TearDown() runs
afterwards, which only checks final state and would not catch a claimed
mid-test scrub or recovery that never happened.

Each TEST_P gets a fresh fixture instance, so each counter starts at 0
for every test. This is pure instrumentation: no behavior change to
production code, and no existing test's assertions or output changed
(confirmed by rebuilding and running the full unittest_ecfailover_with_peering
suite: still 255 passed, 0 failed).

Assisted-by: Claude Sonnet 5 <[email protected]>
Three defects in TestECFailoverWithPeering.cc let tests report success
without exercising what their name or docstring promises.

MultiZoneFailoverWithPeering fails all k+m=6 OSDs of zone 0 (the only
multi-zone config has k=4,m=2,num_zones=2, so min_size = num_zones*(k+m)-m
= 10) but never reduces min_size the way the sibling run_zone_recovery_test
does after an identical whole-zone failure. With only 6 of 12 shards left,
the PG can never reach min_size and activate. The old assertion accepted
any of "Peering", "Active" or "Recovery" in the new primary's state name,
so a PG stuck forever in Peering satisfied it. Tightened to
ASSERT_TRUE(all_shards_active()).

ECMinAvailableTest's headline assertion - that shard 1 is not marked
missing after rejoining - was guarded by `if (primary_ps->is_active())`
with a silent "not active yet" else branch. With this test's shard
bookkeeping (2 shards down in zone 0, then a 3rd, then 1 shard down in
zone 1, then only the zone-0 shard brought back), at most 9 of 12 shards
are ever up again when checked, one short of min_size=10, so the guard's
condition is always false and the assertion inside it dead code. Replaced
the if/else with an unconditional ASSERT_TRUE(primary_ps->is_active())
directly before the peer_missing check.

AddNewZoneWhileSingleZone's docstring claims step 2 scrubs to confirm
consistency with both zones active, and step 5 recovers zone 0's missed
writes - but the test body never calls scrub_object() or
run_recovery()/run_parallel_recovery() at all. Added assertions on the
call counters from the previous commit right after the points the
docstring says these happen, to catch exactly that.

Built and ran (before touching any of the underlying scenario bugs the
next commit fixes):

    ninja unittest_ecfailover_with_peering
    ./bin/unittest_ecfailover_with_peering \
      --gtest_filter='*MultiZoneFailoverWithPeering*:*ECMinAvailableTest*:*AddNewZoneWhileSingleZone*'

This fails 12 of 12 non-skipped instances:

    TestECFailoverWithPeering.cc:572: Failure
    Surviving zone should be fully active after zone failover, primary
    state: Started/Primary/Active/Clean
    [  FAILED  ] .../MultiZoneFailoverWithPeering/EC_ISA_Opt_k4m2_zones2

    TestECFailoverWithPeering.cc:2022: Failure
    PG should be active after bringing shard 1 back online. State:
    Started/Primary/Active/Clean
    [  FAILED  ] .../ECMinAvailableTest/EC_ISA_Opt_k4m2_zones2

    TestECFailoverWithPeering.cc:2167: Failure
    Step 2 should scrub to confirm consistency with both zones active, as
    this test's docstring claims, but scrub_object() was never called
    [  FAILED  ] .../AddNewZoneWhileSingleZone/EC_ISA_Opt_k4m2_su4k
    (and the same failure for all 10 single-zone configs this test runs)

(The MultiZoneFailoverWithPeering and ECMinAvailableTest failure messages
show the *specific* shard/PG queried reports FSM state "Active/Clean" -
all_shards_active()/is_active() still correctly fail because that PG's
own PG_STATE_ACTIVE bit is not set, or another shard in the acting set
is not active; the FSM leaf-state name is not the same thing as the
pg_stat active bit these two helpers actually check.)

For AddNewZoneWhileSingleZone, I also tried the mutation-based approach
suggested by the earlier analysis (make scrub_object() unconditionally
report corruption, rerun the isolated test, expect it to still pass).
That approach turned out to be invalid: PGBackendTestFixture::TearDown()
already runs an unconditional scrub_all_objects() over every object for
any optimized EC pool test that has not otherwise failed, so mutating
scrub_object() makes the always-on teardown scrub (not the missing
inline step-2 scrub this defect is about) fail every EC-optimized test,
including this one - it stopped being a useful signal specifically about
the missing mid-test call. The call-counter approach above avoids that:
it is checked immediately after step 2/step 5, before TearDown() runs.

No fix is included in this commit; that follows next.

Assisted-by: Claude Sonnet 5 <[email protected]>
Fixes the three gaps the previous commit demonstrated failing.

MultiZoneFailoverWithPeering: reduce min_size after failing zone 0's
k+m OSDs, the same way run_zone_recovery_test does after an identical
whole-zone failure. Without this, only k+m of the pool's
num_zones*(k+m) shards remain, permanently below min_size, so the
surviving zone could never actually activate.

ECMinAvailableTest: also bring shard_zone1 back up in step 5, alongside
shard 1. Bringing back only shard 1 left {2, 3, shard_zone1} down - 9 of
12 shards up, one short of min_size (10) - so the PG could never reach
active and the now-unconditional assertion after it would have been
unreachable forever. Restoring shard_zone1 too brings the up-count back
to exactly min_size.

AddNewZoneWhileSingleZone: add the scrub and recovery calls its own
docstring already claimed it made. Scrubbing needs an object that
genuinely exists on every shard, so it scrubs obj_name2 (written to both
zones in step 2) rather than obj_name - obj_name predates zone 1 and is
still pending backfill onto zone-1 shards, so scrubbing it would flag
that legitimate degradation as corruption (confirmed empirically: with
obj_name, scrub_object() reported the zone-1 shards' missing copies as
"corruption"). For recovery, there was nothing to recover before now,
since zone 0 never missed a write; added a write of a new third object
while zone 0 is down so it has something genuine to recover once it
rejoins, and pass recover_primary=true because the primary reverts to
zone 0 once its OSDs come back up (they sort first in the acting set),
and that primary is exactly the one that missed the write.

Built and ran:

    ninja unittest_ecfailover_with_peering
    ./bin/unittest_ecfailover_with_peering \
      --gtest_filter='*MultiZoneFailoverWithPeering*:*ECMinAvailableTest*:*AddNewZoneWhileSingleZone*'
    [  PASSED  ] 12 tests.

    ./bin/unittest_ecfailover_with_peering
    [  PASSED  ] 257 tests.

Assisted-by: Claude Sonnet 5 <[email protected]>
global.yaml.in's default osd_pool_default_erasure_code_profile
carries "num_zones=1", added by "mon: Add num_zones into EC
profile." under a design where the erasure-code layer read num_zones
back out of the ErasureCodeProfile map. That design was superseded:
every real consumer of num_zones now takes it as an explicit
function parameter (ErasureCode::create_rule) or a separate
pool_opts_t::NUM_ZONES option, never a profile-map lookup. No code
anywhere does profile_map["num_zones"] or profile.find("num_zones")
any more, so the key just rides along, unread, into every
default/created EC profile and is visible to users via
`ceph osd erasure-code-profile get`.

Add OSDMonitorStretchTest.DefaultProfileHasNoDeadNumZonesKey, which
calls OSDMap::get_erasure_code_profile_default() - the exact helper
used by both the mkfs bootstrap path and OSDMonitor::prepare_new_pool's
auto-profile path - and asserts the resulting profile map has no
"num_zones" entry. Right now it does, so this test fails:

  Expected equality of these values:
    profile_map.count("num_zones")
      Which is: 1
    0u
      Which is: 0

Verified with: ninja unittest_osd_monitor &&
  ./bin/unittest_osd_monitor --gtest_filter=*DefaultProfileHasNoDeadNumZonesKey*
(1 test run, 1 failed; the rest of the suite - 14 other tests - still
pass, unaffected).

The fix follows in the next commit.

Assisted-by: Claude Sonnet 5 <[email protected]>
The default osd_pool_default_erasure_code_profile string carried
"num_zones=1" ever since "mon: Add num_zones into EC profile.", back
when the erasure-code layer read num_zones back out of the
ErasureCodeProfile map. That design has since been superseded:
num_zones now flows only as an explicit function/cmdmap parameter
(ErasureCodeInterface::create_rule, OSDMonitor's
crush_rule_create_erasure/replica helpers) or as the separate
pool_opts_t::NUM_ZONES pool option - never a profile-map lookup. A
repo-wide grep confirms nothing does profile_map["num_zones"] or
profile.find("num_zones") any more.

With no consumer left, the key was just dead weight that got baked
into every default/created EC profile and leaked out through
`ceph osd erasure-code-profile get`. Drop it.

Note for whoever reads history: the commit titled "mon: Add num_zones
into EC profile." no longer describes anything real once this key is
gone (its own OSDMonitor.cc changes were superseded by the
pool_opts_t::NUM_ZONES-based design too) - left as-is per instructions,
not reworded.

Verified with: ninja unittest_osd_monitor &&
  ./bin/unittest_osd_monitor --gtest_filter=*DefaultProfileHasNoDeadNumZonesKey*
  -> now PASSES (previously failing test from the prior commit).
Full unittest_osd_monitor suite: 15/15 tests pass.

Assisted-by: Claude Sonnet 5 <[email protected]>
Works for both ec and replica pools, supporting changes from 1 -> 2 zones and vice versa.

Signed-off-by: Callum James <[email protected]>
Rather than relying on sonfig variables, automatically caluclate size for replica pools when moving between stretch and non stretch. Also adds new tests for replica pools with varying number of replicas

Signed-off-by: Callum James <[email protected]>
- new helper functions to validate and commit per pool stretch
- new helper function to tear down cluster-level stretch mode if pool is the last pool that still had stretch mode enabled

Signed-off-by: Callum James <[email protected]>
…ti-site and vice vera.

Rather than hardcode replicas_per_zone to 2, maintain the pools previous value.

Signed-off-by: Callum James <[email protected]>
Signed-off-by: Callum James <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

kamoltat added a commit that referenced this pull request Sep 29, 2026
- Added TEST(ECPoolCreatePP, ReplicatedPoolSetNumZones)
- Added TEST(ECPoolCreatePP, ErasurePoolSetNumZones)
- Added OSDMonitor::maybe_remove_unused_crush_rule

Signed-off-by: Callum James <[email protected]>
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
kamoltat added a commit that referenced this pull request Sep 29, 2026
- Added TEST(ECPoolCreatePP, ReplicatedPoolSetNumZones)
- Added TEST(ECPoolCreatePP, ErasurePoolSetNumZones)
- Added OSDMonitor::maybe_remove_unused_crush_rule

Signed-off-by: Callum James <[email protected]>
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
@kamoltat

Copy link
Copy Markdown
Collaborator

As discussed with @CJamesIBM , we have decided to squash this PR into #35 since there are overlapping changes. The code changes that has been cherry-picked can be found in this commit: daa573c

kamoltat added a commit that referenced this pull request Oct 2, 2026
- Added TEST(ECPoolCreatePP, ReplicatedPoolSetNumZones)
- Added TEST(ECPoolCreatePP, ErasurePoolSetNumZones)
- Added OSDMonitor::maybe_remove_unused_crush_rule

Signed-off-by: Callum James <[email protected]>
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
@aainscow
aainscow force-pushed the stretchy-C branch 2 times, most recently from 88be5d1 to fb56ba2 Compare October 5, 2026 15:36
aainscow pushed a commit that referenced this pull request Oct 7, 2026
- Added TEST(ECPoolCreatePP, ReplicatedPoolSetNumZones)
- Added TEST(ECPoolCreatePP, ErasurePoolSetNumZones)
- Added OSDMonitor::maybe_remove_unused_crush_rule

Conflicts (rebased onto stretchy-C):
  src/mon/OSDMonitor.h: maybe_remove_unused_crush_rule() is now declared
    by "mon: support entering/exiting per pool stretch-mode via
    num_zones", which defines it.

Signed-off-by: Callum James <[email protected]>
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
aainscow pushed a commit that referenced this pull request Oct 7, 2026
- Added TEST(ECPoolCreatePP, ReplicatedPoolSetNumZones)
- Added TEST(ECPoolCreatePP, ErasurePoolSetNumZones)
- Added OSDMonitor::maybe_remove_unused_crush_rule

Conflicts (rebased onto stretchy-C):
  src/mon/OSDMonitor.h: maybe_remove_unused_crush_rule() is now declared
    by "mon: support entering/exiting per pool stretch-mode via
    num_zones", which defines it.

Signed-off-by: Callum James <[email protected]>
Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
@aainscow

Copy link
Copy Markdown
Owner

Closing — these commits were folded into the stretchy-C integration branch (9932e1b, plus the size/min_size and global-stretch-mode follow-up fixes), so the feature and its fixes are already on stretchy-C. Thanks @CJamesIBM!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants