Skip to content

tentacle: mds: introduce standby anti-affinity scoring matrix - #73569

Open
anthonyeleven wants to merge 8 commits into
ceph:tentaclefrom
anthonyeleven:wip-82050-tentacle
Open

anthonyeleven wants to merge 8 commits into
ceph:tentaclefrom
anthonyeleven:wip-82050-tentacle

Conversation

@anthonyeleven

@anthonyeleven anthonyeleven commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

backport tracker: https://tracker.ceph.com/issues/82050


backport of #69801
parent tracker: https://tracker.ceph.com/issues/75892

also includes the commit from #67853 (doc/cephfs: Fix spelling etc errors), which has no tracker. The doc commit from #69801 conflicts in doc/cephfs/standby.rst without it. The #67853 cherry-pick needed conflict resolution in 6 doc/cephfs files where tentacle's text differs from main, and the #69801 doc commit needed it in PendingReleaseNotes.

This PR introduces a multi-tiered standby selection scoring matrix to the MDS Monitor to dynamically prioritise anti-affinity over software rules, protecting the cluster's failure domains.

  • Score-Based Selection Matrix: Implements a graded scoring matrix (Scores 1 to 6) across FSMap and MDSMonitor, that ensures both primary replacements and standby-replay followers are strictly barred from co-locating on the same physical host as an active or failing rank. This ensures different-host standbys strictly outrank same-host candidates.

  • Testing Coverage: Adds a dedicated unit tests verifying 6 distinct cases alongside a python functional QA task verifying live orchestration (with a scope limitation).

  • Documentation: Updates PendingReleaseNotes and standby.rst to accurately map out the new selection grid, score tiers, and state recovery behaviours.

Cherry-pick of the 6 commits, with the same line changes as on main, after one more pick:

  • First commit, from doc/cephfs: Fix spelling etc errors #67853 (bluikko's "doc/cephfs: Fix spelling etc errors", merged on main before this PR): only its doc/cephfs/standby.rst changes, which capitalize "Monitors" as main does. With it, the doc commit picks cleanly, and standby.rst ends up identical to main's after this PR. The rest of doc/cephfs: Fix spelling etc errors #67853, which was never backported, is not included. Its Conflicts block says so, and the Backport Audit will need an override for it.
  • PendingReleaseNotes: the doc commit's pick also brought in entries that exist only on main; I kept only this change's entry, as its Conflicts block says.

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.

bluikko and others added 7 commits November 5, 2026 21:59
Signed-off-by: Ville Ojamo <[email protected]>
(cherry picked from commit 4766f3b)

Conflicts:
	doc/cephfs/standby.rst
	- took only this file, the one the next commits change, so that it
	  matches main's wording; the rest of this commit is not part of
	  this backport
In the past, standby selection did not account for failure domains,
allowing a standby daemon to be assigned or promoted on the exact
same physical host as the active daemon it was intended to back up.

This commit introduces a score-based anti-affinity matrix to FSMap
and updates MDSMonitor allocation loops to pass target addresses.
This strictly prioritizes remote standbys (different host) over
same-host standbys for both active replacements and standby-replay
assignments to maximize failure domain isolation. The logic handles
hot updates and cold crash recoveries by enforcing anti-affinity.

Additionally, this introduces the `standby_enable_host_anti_affinity`
per-filesystem setting (managed via `ceph fs set`, default: true) to
allow users to explicitly toggle this behavior. When set to `false`,
the selection algorithm bypasses the host isolation checks, scoring all
standbys in the `SCORE_PREF_*` tier. This effectively restores the legacy
behavior where strict `mds_join_fs` preferences win unconditionally,
regardless of physical placement.

Fixes: https://tracker.ceph.com/issues/75892
Signed-off-by: Jos Collin <[email protected]>
(cherry picked from commit 7d937a7)
Introduce a dedicated test in src/test/mds/TestStandbyAffinity.cc to
directly validate the score-based selection matrix inside FSMap.

The test case evaluates three core topology distribution scenarios:
1. Cross-tier prioritization: Ensuring a remote vanilla standby
   outscores an explicit FSCID match residing on the same host.
2. Short-circuit optimization: Confirming immediate selection when a
   perfect candidate (matching FSCID + different host) is found.
3. Fallback graceful degradation: Verifying that standard affinity
   preferences are preserved if all available standbys share the
   active daemon's host.
4. Multi-active avoidance: Proving the matrix correctly avoids an
   array of multiple hosts when a filesystem has multiple active ranks.
5. Deterministic tie-breaking: Ensuring the algorithm safely and
   predictably selects a winner when multiple remote candidates share
   the exact same maximum score.
6. Excluded host standby avoidance: Verifying that the host penalty
   is correctly applied to override a filesystem match when a standby
   resides on an excluded host, safely promoting a clean vanilla candidate.
7. Feature flag disabled: Validating that disabling the filesystem's
   'standby_enable_host_anti_affinity' MDSMap flag successfully
   bypasses host penalties and restores legacy scoring logic.

Fixes: https://tracker.ceph.com/issues/75892
Signed-off-by: Jos Collin <[email protected]>
(cherry picked from commit e9f5cd4)
Introduce a functional integration test to validate the end-to-end configuration
and wire communication pipeline for MDS standby affinity during a live failover.

test_standby_affinity_promotion: Forces a failover scenario to ensure that an
operator's 'mds_join_fs' configuration safely propagates from a live daemon's
beacon to the MDSMonitor, correctly resulting in the priority promotion of a
preferred standby over a generic vanilla option.

Additionally, this updates the CephFS QA framework (filesystem.py) to explicitly
disable `standby_enable_host_anti_affinity` by default when creating test
filesystems. Because Teuthology densely packs MDS daemons onto limited nodes,
legacy failover tests will timeout if hardware anti-affinity is strictly enforced.
However, the feature is now safely opted-into for this specific test suite via a YAML
override in `tasks/standby-affinity.yaml`.

Scope Limitation:
This QA test is intentionally scoped as a basic integration smoke test to verify
the configuration plumbing and daemon-to-monitor protocol. Because teuthology
environments typically spin up on single test nodes or do not guarantee isolated
multi-host topologies, fine-grained scoring matrix scenarios (such as the host
anti-affinity subtraction loops where active_addrs is evaluated) are decoupled and
validated via unit test cases in src/test/mds/TestStandbyAffinity.cc instead.

Fixes: https://tracker.ceph.com/issues/75892
Signed-off-by: Jos Collin <[email protected]>
(cherry picked from commit 1720ae0)
Update the file system affinity documentation to accurately detail the
multi-tiered scoring engine used by the Monitors during failover.

Explicitly documents the priority scoring matrix (Scores 1 through 6)
and clarifies how the selection engine balances software-defined
'mds_join_fs' configurations against physical host anti-affinity rules.
This includes the 'standby_enable_host_anti_affinity' per-filesystem
toggle (configured via 'ceph fs set') that allows operators to opt-out
of host penalties.

Additionally, define the behavioral distinctions across the three
core anti-affinity rules: Hot Takeovers, Stale/Purged Topology
Recovery, and Cross-FS Failover Restrictions.

Updated the PendingReleaseNotes highlighting the new tiered scoring
matrix and the per-filesystem configuration toggle used during standby
promotion cycles.

Fixes: https://tracker.ceph.com/issues/75892
Signed-off-by: Jos Collin <[email protected]>
(cherry picked from commit 6762adc)

Conflicts:
	PendingReleaseNotes
	- the pick also brought in entries that are only on main; kept only
	  this one
The recent introduction of the 'standby_enable_host_anti_affinity'
per-filesystem setting added a new boolean field to the MDSMap
JSON dump.

This commit updates the __mdsmap_schema in test_health.py to
expect this new 'standby_enable_host_anti_affinity' key,
resolving the dashboard API validation failure in the CI.

Fixes: https://tracker.ceph.com/issues/75892
Signed-off-by: Jos Collin <[email protected]>
(cherry picked from commit 8ba34b8)
This commit fixes a long-standing race condition in test_failover.py.
Previously, the test would update the mds_join_fs configuration for a
standby daemon and immediately force an MDS rank failure. This created
a timing window where the MDSMonitor could evaluate standby candidates
using stale configuration data.

Historically, this race was masked by the legacy fallback tie-breaker
logic, which often coincidentally promoted the correct daemon. However,
with stricter, deterministic tie-breaking, this missing synchronization
barrier caused unexpected promotion failures.

By adding `self._reach_target(target)` before `self.fs.rank_fail()`,
we establish a proper synchronization barrier. This guarantees that the
Monitor has fully processed the configuration update before the failover
event is triggered, ensuring test determinism and eliminating flakiness.

Signed-off-by: Jos Collin <[email protected]>
(cherry picked from commit b219b2b)
github-actions[bot]

This comment was marked as outdated.

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label Nov 6, 2026
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

/audit override

@github-actions github-actions Bot added releng-audit-override and removed releng-audit-fail Release engineering: failed backport verification audit. labels Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

✅ Audit Override Applied by @anthonyeleven.

View workflow run

The standby host anti-affinity backported from main changes how the
monitors pick a standby, so on this release it is off by default and a
cluster opts in per file system with:

  ceph fs set <fs_name> standby_enable_host_anti_affinity true

A cluster upgrading from a release without the flag decodes it as
false and keeps its existing standby selection. The unit test fixture
now enables the flag, since every scenario except the flag-disabled
one tests the enabled behavior. The release note and the standby docs
now describe the flag as off by default.

This commit is specific to the backport: on main the flag defaults to
true. Agreed on https://tracker.ceph.com/issues/75892.

Fixes: https://tracker.ceph.com/issues/82050
Signed-off-by: Anthony D'Atri <[email protected]>
Assisted-by: Claude Opus 5.5
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

@joscollin As agreed on https://tracker.ceph.com/issues/75892, 899f9b5 makes standby_enable_host_anti_affinity default to false on tentacle: the MDSMap initializer, the release note and the standby docs. The unit test fixture now enables the flag for the scenarios that test it. Could you review?

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

⚠️ Audit Override Removed

New commits were pushed to this PR, so the previous override has been removed.

View workflow run

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ceph Release Engineering Audit Report

Automated Redmine Linkage Audit

The following tracking irregularities were found:

  • Orphaned Main PR: Could not find a Redmine tracker for main PR #67853. Please create a ticket, set its 'Pull Request ID', populate the 'Backport' field, and ensure it is in the 'Pending Backport' state.

Automated Backport Parity Review - Invalid Commit Format

The following commits have an invalid format. Backport commits must either include a standard (cherry picked from commit ...) line or start with the target branch name (e.g., tentacle:).

  • 899f9b51 mds: disable standby host anti-affinity by default on tentacle

Be familiar with the rules and guidelines for writing backports.


Automated Backport Parity Review

⚠️ Multiple Original PRs Detected: PR #67853, PR #69801

Discrepancies detected between the backport PR and the original source PR(s). Please see the Commit Parity Visualizer below.


Commit Parity Visualizer

BACKPORT PR #73569 SOURCE PR SOURCE STATUS
e2b1fae doc/cephfs: Fix spelling etc errors PR #67853 4766f3b doc/cephfs: Fix spelling etc errors
fd8682d mds: introduce host anti-affinity for standby selection PR #69801 7d937a7 mds: introduce host anti-affinity for standby selection
576be05 src/test: add unit tests for standby anti-affinity selection e9f5cd4 src/test: add unit tests for standby anti-affinity selection
9961c44 qa: add teuthology suite for mds standby affinity 1720ae0 qa: add teuthology suite for mds standby affinity
52ff09f doc: document MDS standby promotion scoring matrix and anti-affinity 6762adc doc: document MDS standby promotion scoring matrix and anti-affinity
4a75130 qa/dashboard: update mdsmap schema for standby anti-affinity 8ba34b8 qa/dashboard: update mdsmap schema for standby anti-affinity
1fc8451 qa/tasks/cephfs: fix race condition in TestClusterAffinity b219b2b qa/tasks/cephfs: fix race condition in TestClusterAffinity
899f9b5 mds: disable standby host anti-affinity by default on tentacle <<<< EXTRA IN BACKPORT >>>>

Automated Backport Parity Review - Cherry-Pick Conflicts / Deviations

⚠️ WARNING: Cherry-pick conflicts or deviations were found that require component lead review.

A conflict or deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.

This does not necessarily indicate an issue but a maintainer should review.

**Click to expand conflict summaries.**

Deviation in Backport e2b1fae (cherry-pick of 4766f3b)

Affected File(s)

Range Diff

Click to expand
--- Original (4766f3b3)
+++ Backport (e2b1fae2)
@@ -1,3 +1,10 @@
 doc/cephfs: Fix spelling etc errors
 
 Signed-off-by: Ville Ojamo <[email protected]>
+(cherry picked from commit 4766f3b331e64935994042b64b414f52665a6b62)
+
+Conflicts:
+	doc/cephfs/standby.rst
+	- took only this file, the one the next commits change, so that it
+	  matches main's wording; the rest of this commit is not part of
+	  this backport

================================================================================
RANGE DIFF
================================================================================

1:  4766f3b331e < -:  ----------- doc/cephfs: Fix spelling etc errors
-:  ----------- > 1:  e2b1fae2f80 doc/cephfs: Fix spelling etc errors

Deviation in Backport 52ff09f (cherry-pick of 6762adc)

Affected File(s)

Range Diff

Click to expand
--- Original (6762adce)
+++ Backport (52ff09f8)
@@ -20,3 +20,9 @@
 
 Fixes: https://tracker.ceph.com/issues/75892
 Signed-off-by: Jos Collin <[email protected]>
+(cherry picked from commit 6762adce863196cdbcd24ea0b8f4055e8947db83)
+
+Conflicts:
+	PendingReleaseNotes
+	- the pick also brought in entries that are only on main; kept only
+	  this one

================================================================================
RANGE DIFF
================================================================================

1:  6762adce863 ! 1:  52ff09f81de doc: document MDS standby promotion scoring matrix and anti-affinity
    @@ Commit message
     
         Fixes: https://tracker.ceph.com/issues/75892
         Signed-off-by: Jos Collin <[email protected]>
    +    (cherry picked from commit 6762adce863196cdbcd24ea0b8f4055e8947db83)
    +
    +    Conflicts:
    +            PendingReleaseNotes
    +            - the pick also brought in entries that are only on main; kept only
    +              this one
     
      ## PendingReleaseNotes ##
     @@
    -   re-execs under GNU bash >= 4 when the system bash is too old, and honors a
    -   ``$GETOPT`` environment override so GNU getopt can be selected
    -   (``brew install bash gnu-getopt``).
    +   ``cpu_isa_level`` host fact (e.g. ``x86-64-v2``). The check can be disabled
    +   with ``ceph config set mgr mgr/cephadm/upgrade_cpu_isa_check false``, e.g.
    +   when running custom-built images targeting an older CPU generation.
     +* CephFS: Added a multi-tiered scoring matrix to the MDS Monitor to dynamically
     +  prioritize standby promotion during failover events. The `mds_join_fs` configuration
     +  variable is now checked in combination with infrastructure topology rules to enforce
    @@ PendingReleaseNotes
     +  `ceph fs set <fs_name> standby_enable_host_anti_affinity false` (default: true)
     +  to restore legacy strict 'mds_join_fs' prioritization.
      
    - * CephFS: New MDS configuration options for non-blocking dirfrag prefetch have
    -   been added. ``mds_dir_prefetch_backend``, when enabled with
    + * RADOS: PG autoscaler allows overlapping roots. Each root receives a PG target based
    +   on its OSDs, with OSDs shared across multiple roots contributing proportionally
     
      ## doc/cephfs/standby.rst ##
     @@ doc/cephfs/standby.rst: standby on modest or over-provisioned systems. To configure this preference,

How to proceed:

  • Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git Conflicts: block intact) and include an explanation for changes.
  • Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
  • Component Leads (Review): Please review the Range Diff(s) above to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting /audit override.

Be familiar with the rules and guidelines for writing backports.


🛟 Need Help?

If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.

📋 Component Lead / Release Manager

To override the audit failure, apply releng-audit-override label or comment /audit override.


⚠️ Note: Automated audit checks will be suspended on future pushes to prevent comment spam while you work.

When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.

View workflow run

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label Nov 8, 2026
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

/audit override

@github-actions github-actions Bot added releng-audit-override and removed releng-audit-fail Release engineering: failed backport verification audit. labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

✅ Audit Override Applied by @anthonyeleven.

View workflow run

@joscollin joscollin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The changes looks good. Please take it through QA and merge. Thanks @anthonyeleven

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath31-testing-20261114.234838-tentacle.

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

Thank you. Tracker had been idle for 7 months. The community benefits from these backports.

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test dashboard cephadm

1 similar comment
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test dashboard cephadm

@ronen-fr

Copy link
Copy Markdown
Contributor

RADOS-approved. See https://tracker.ceph.com/projects/rados/wiki/TENTACLE#httpstrackercephcomissues83181

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test dashboard cephadm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Reviewer approved

Development

Successfully merging this pull request may close these issues.

5 participants