Project

General

Profile

Actions

Bug #79106

closed
SM NM

mgr: dispatch_remote() records a crash dump for NotImplementedError, so the documented orchestrator "ask for forgiveness" pattern pins RECENT_MGR_MODULE_CRASH forever

Bug #79106: mgr: dispatch_remote() records a crash dump for NotImplementedError, so the documented orchestrator "ask for forgiveness" pattern pins RECENT_MGR_MODULE_CRASH forever

Added by Sebastian Marschke 4 months ago. Updated 3 months ago.

Status:
Resolved
Priority:
Urgent
Category:
ceph-mgr
Target version:
-
Due date:
% Done:

0%

Source:
Backport:
tentacle, umbrella
Regression:
Yes
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-1987-g5513ae2a1c
Released In:
Upkeep Timestamp:
2026-08-27T18:45:41+00:00

Description

Summary

ActivePyModule::dispatch_remote() asks handle_pyerror() for a crash dump on every exception raised by the callee, including NotImplementedError. But NotImplementedError is not a fault — it is the documented way a module signals that it does not implement an optional method of an interface it inherits from, and the whole orchestrator interface is built on that convention.

The result is that following the documented convention still produces a crash record. On a Rook-managed cluster this fires once per Prometheus scrape: HEALTH_WARN RECENT_MGR_MODULE_CRASH is raised within minutes, never clears again, and the crash database grows by ~5,760 records per day.

This is a regression in v20.2.3 — the collector that triggers it does not exist in v20.2.2, and the C++ behaviour it runs into has been dormant since 2021. Details under "This is a regression in v20.2.3" below.

Nothing breaks functionally — metric collection is unaffected and no daemon restarts — but the cluster can never report HEALTH_OK again, so every genuine warning is buried.

A patch is attached.

Environment

ceph version 20.2.3 (06c2f9c35b67055a8a6fb99d1be236b3c4832ace) tentacle (stable)
container:    quay.io/ceph/ceph:v20.2.3
orchestrator: {"available": true, "backend": "rook"}
Rook:         rook/ceph:v1.20.2
Kubernetes:   v1.35.6
OS (mgr):     CentOS Stream 9 container on Talos Linux v1.13.5, kernel 6.18.36

3 mons, 2 mgr, 9 OSDs, 1 MDS + standby, 1 RGW. Cluster data state healthy throughout: 713 PGs active+clean, 9/9 OSDs up and in, zero daemon restarts.

Symptom

# ceph health detail
HEALTH_WARN 1430 mgr modules have recently crashed
[WRN] RECENT_MGR_MODULE_CRASH: 1430 mgr modules have recently crashed
    mgr module rook crashed in daemon mgr.a on host <node> at 2026-08-05T20:52:40.772946Z
    mgr module rook crashed in daemon mgr.a on host <node> at 2026-08-05T20:52:55.453220Z

Crash record:

{
    "backtrace": [
        "  File \"/usr/share/ceph/mgr/orchestrator/_interface.py\", line 369, in node_proxy_fullreport\n    raise NotImplementedError()",
        "NotImplementedError" 
    ],
    "ceph_version": "20.2.3",
    "entity_name": "mgr.a",
    "mgr_module": "rook",
    "mgr_module_caller": "ActivePyModule::dispatch_remote node_proxy_fullreport",
    "mgr_python_exception": "NotImplementedError",
    "process_name": "ceph-mgr",
    "stack_sig": "9f2dcab3cd0618586c4ed9eb9b61dde25253e548666afd097706dbeba04c625a" 
}

The rate is exactly the scrape interval

Records per hour from ceph crash ls. The cluster was upgraded to 20.2.3 at 2026-08-05 20:52 and the first record of this signature carries that timestamp.

2026-08-05T20   34     <- upgrade completed 20:52
2026-08-05T21  240
2026-08-05T22  240
2026-08-05T23  240
2026-08-06T00  240
2026-08-06T01  240
2026-08-06T02  240
2026-08-06T03  240

Per minute, twelve consecutive minutes, no deviation:

2026-08-06T04:34   4
2026-08-06T04:35   4
2026-08-06T04:36   4
...                4

240/h = 4/min = one record every 15 s, which is exactly the default mgr/prometheus/scrape_interval.

The Python side is correct at every level

This is worth spelling out, because it shows the defect is not in mgr/prometheus.

  1. Orchestrator.node_proxy_fullreport() raises NotImplementedError (src/pybind/mgr/orchestrator/_interface.py:369) — the base class contract for a method only cephadm implements. The Rook module does not override it (no occurrence of node_proxy in src/pybind/mgr/rook/module.py).
  2. Orchestrator.get_feature_set() reports exactly that, by comparing the subclass against the base class.
  3. OrchestratorClientMixin._oremote() uses it to convert the failed remote call back into the right exception type for the caller.
  4. mgr/prometheus.get_hardware_metrics() then handles it exactly as the get_feature_set() docstring instructs — "It's better to ask for forgiveness instead: try: ... except (OrchestratorError, NotImplementedError)".

The relevant code, in order:

# _interface.py, get_feature_set()
features = {a: {'available': getattr(Orchestrator, a, None) != getattr(module, a)}
            for a in Orchestrator.__dict__ ...}

# _interface.py, OrchestratorClientMixin._oremote()
try:
    return mgr.remote(o, meth, *args, **kwargs)
except Exception as e:
    if meth == 'get_feature_set':
        raise
    f_set = self.get_feature_set()
    if meth not in f_set or not f_set[meth]['available']:
        raise NotImplementedError(f'{o} does not implement {meth}') from e
    raise

# prometheus/module.py, get_hardware_metrics()
try:
    report = raise_if_exception(self.node_proxy_fullreport())
except Exception as e:
    self.log.debug(f"node-proxy data not available: {e}")
    return

Every layer does the right thing. The crash record is created underneath all of it, in C++.

Root cause

src/mgr/ActivePyModule.cc:193:

  auto ret = PyObject_Call(boundMethod, args, kwargs);
  ...
  if (ret == nullptr) {
    std::string caller = "ActivePyModule::dispatch_remote "s + method;
    *err = handle_pyerror(true, get_name(), caller);   // <- unconditional crash dump
    return std::nullopt;
  }

and src/mgr/PyModule.cc:113:

std::string handle_pyerror(bool crash_dump, std::string module, std::string caller)
{
  ...
  if (!module.empty()) {          // <- crash_dump is never read
    ...
    generate_crash_dump(crash_path, bt, &extra);
  }

Two things stand out:

  • dispatch_remote() cannot distinguish a genuine module fault from a deliberate NotImplementedError, and asks for a dump either way.
  • handle_pyerror() has taken a crash_dump parameter since it was introduced but never reads it — the dump is emitted whenever a module name was passed. The flag is dead. (Every current caller that passes a module name also passes crash_dump=true, so honouring it changes no existing behaviour.)

Impact

  • HEALTH_WARN is permanently occupied; ceph health detail becomes unusable and real warnings are masked. ceph crash archive-all clears it for one scrape interval.
  • Tooling that derives state from Ceph health reports the cluster degraded indefinitely. In our case Argo CD holds rook-ceph-cluster at Degraded, which gates deployment ordering.
  • ~5,760 crash records per day. There is no config option to disable the collector: ceph config ls | grep mgr/prometheus offers only cache, exclude_perf_counters, healthcheck_history_max_entries, log_*, rbd_stats_*, scrape_interval, server_*, sqlite3_killpoint, stale_cache_strategy, standby_*.
  • No data or metric loss: :9283/metrics still serves 1533 lines including ceph_health_status. hardware_* is empty, which is correct — those values come from the cephadm node-proxy agent.

The only workaround available to operators is ceph health mute RECENT_MGR_MODULE_CRASH --sticky, which also silences genuine mgr module crashes. Non-sticky muting is useless because the count changes every 15 s.

This is a regression in v20.2.3

get_hardware_metrics() does not exist in v20.2.1 or v20.2.2, nor in the squid or reef branches. It appears for the first time in v20.2.3, which matches the observed timeline exactly: the very first crash record of this signature carries the timestamp of the 20.2.3 upgrade, and the cluster had been running 20.2.2 for weeks before that without a single one.

grep -c "def get_hardware_metrics" src/pybind/mgr/prometheus/module.py

  v20.2.1   0
  v20.2.2   0
  v20.2.3   1
  tentacle  1
  main      1
  squid     0
  reef      0

Only Tentacle is affected; no backport to older releases is needed.

How it got there:

  • aa8f05400 (2026-06-11) "mgr/prometheus: add node-proxy hardware metrics exporter" added the collector. It read cephadm's KV store directly.
  • 6bb07c6e5 (2026-06-25) "mgr/prometheus: use orchestrator API for node-proxy hardware metrics" switched it to node_proxy_fullreport() / node_proxy_firmware() via OrchestratorClientMixin. This is the change that put a call which is guaranteed to raise on every non-cephadm backend onto the per-scrape path.

That commit states it "Follows the same pattern as set_cephadm_daemon_status_metrics() and get_smb_metadata()" — and that is where the missing piece is. get_smb_metadata() does not only check self.available(), it first checks that the providing module is actually there:

mgr_map = self.get('mgr_map')
enabled_modules = mgr_map['modules']
if 'smb' not in enabled_modules:
    self.log.debug("SMB module is not enabled, skipping SMB metadata collection")
    return

if not self.available()[0]:
    self.log.debug("Orchestrator not available")
    return

get_hardware_metrics() has only the second half of that. It has no equivalent of the first check, and orch_is_available() is true on Rook — the orchestrator is available, it just does not implement node-proxy.

The C++ side is old and was simply never hit this way before: 719d5e183 (2021-06-18) "mgr: generate crash dump for python exceptions" introduced the behaviour five years ago. Nothing put a guaranteed-raising remote call on a per-scrape path until now.

I could not find an open PR addressing this (GitHub PR search for node_proxy in ceph/ceph returned no open matches), nor an existing tracker issue for node_proxy_fullreport or get_hardware_metrics.

Reproduction

Passive, on any Rook-managed Ceph 20.2.x where ceph orch status reports {"available": true, "backend": "rook"}:

  1. Leave the prometheus mgr module enabled (default).
  2. watch 'ceph crash ls | wc -l' — grows by one every mgr/prometheus/scrape_interval seconds.
  3. ceph health detail shows RECENT_MGR_MODULE_CRASH within minutes and never clears.

Single-command reproducer, no Prometheus involved. This is the more interesting one, because it shows the problem is not specific to mgr/prometheus or to node_proxy_fullreport — an administrator simply typing an unsupported ceph orch command leaves a crash record behind:

# ceph orch hardware status
Error ENOENT: This Orchestrator does not support `orch hardware status`

The CLI handles it correctly (OrchestratorCLICommandBase.__call__ in src/pybind/mgr/orchestrator/cli.py:24 catches NotImplementedError and prints that message), but a crash dump was written anyway:

{
  "backtrace": ["  File \"/usr/share/ceph/mgr/orchestrator/_interface.py\", line 361, in node_proxy_summary\n    raise NotImplementedError()",
                "NotImplementedError"],
  "timestamp": "2026-08-06T05:16:51.396080Z",
  "mgr_module": "rook",
  "mgr_module_caller": "ActivePyModule::dispatch_remote node_proxy_summary",
  "mgr_python_exception": "NotImplementedError",
  "stack_sig": "270ae6167f991a7541836b848aba4f1360a0b0fa28105b719b8180a8d9535097" 
}

One record per invocation, verified on disk. ceph crash ls lags behind because records are only visible once the crash daemon has posted them; the dumps themselves appear immediately in the mgr's crash_dir (generate_crash_dump() in src/global/signal_handler.cc:154 writes a fresh directory with a unique id every time — there is no dedup or rate limit):

mgr# ls /var/lib/ceph/crash | wc -l        # pending
15
mgr# ls /var/lib/ceph/crash/posted | wc -l # already posted
2040

so ceph orch hardware status --category criticals right afterwards produced its own directory too.

With the attached patch that command should still return This Orchestrator does not support ... and leave no crash dump behind.

Proposed fix

Attached patch, two hunks:

  • ActivePyModule::dispatch_remote() — request no crash dump when the callee raised NotImplementedError:
const bool crash_dump = !PyErr_ExceptionMatches(PyExc_NotImplementedError);

The exception is still returned to the caller and re-raised in its context; only the dump is skipped. (PyErr_ExceptionMatches is already used this way in PyModule.cc:549, and the GIL is held at this point.)

  • handle_pyerror() — honour the crash_dump parameter that has always been there.

I chose the core rather than mgr/prometheus because it covers every present and future cephadm-only call reaching a non-cephadm backend, not just this one instance.

That said, since this is a v20.2.3 regression you may prefer a second, narrower change alongside it for the point release — giving get_hardware_metrics() the check that get_smb_metadata() already has, so the dispatch does not happen at all on a backend that cannot serve it. I have not written that one because I am not sure which check you would consider canonical here: node-proxy has no module of its own to look up in mgr_map, so it would have to be either a get_feature_set() lookup (an extra remote call per scrape, which is why I left it alone) or an explicit backend test. Happy to follow whichever you prefer.

Remaining after the patch

ceph_dispatch_remote() in BaseMgrModule.cc:930 still logs

-1 Remote method threw exception: ... NotImplementedError

at error level on every occurrence, because at that point only the formatted string is available, not the exception type. Silencing that too would mean plumbing a flag out of dispatch_remote() through ActivePyModules::dispatch_remote(). I left it out to keep the patch minimal — happy to extend it if you would prefer that.


Files

cephfixnotimplementederror.patch (4.42 KB) cephfixnotimplementederror.patch Sebastian Marschke, 08/06/2026 05:56 AM

Related issues 3 (0 open — 3 closed)

Related to mgr - Bug #79357: Module 'crash' has experienced an error and cannot handle commands: dictionary changed size during iterationBackportingNitzan Mordechai

Actions
Copied to mgr - Backport #79396: umbrella: mgr: dispatch_remote() records a crash dump for NotImplementedError, so the documented orchestrator "ask for forgiveness" pattern pins RECENT_MGR_MODULE_CRASH foreverResolvedLaura Flores

Actions
Copied to mgr - Backport #79397: tentacle: mgr: dispatch_remote() records a crash dump for NotImplementedError, so the documented orchestrator "ask for forgiveness" pattern pins RECENT_MGR_MODULE_CRASH foreverResolvedNitzan Mordechai

Actions

YH Updated by Yaarit Hatuka 4 months ago Actions #1

  • Priority changed from Normal to Urgent
  • Backport changed from tentacle to tentacle, umbrella

PS Updated by Phillip Schichtel 4 months ago Actions #2

This is also quite unfortunate:

bash-5.1$ ceph crash ls
Error EIO: Module 'crash' has experienced an error and cannot handle commands: dictionary changed size during iteration
bash-5.1$ ceph crash archive-all
Error EIO: Module 'crash' has experienced an error and cannot handle commands: dictionary changed size during iteration

I assume this is due to the large amount of crashes (this is after about 24h)

NM Updated by Nitzan Mordechai 4 months ago Actions #3

  • Status changed from New to In Progress
  • Assignee set to Nitzan Mordechai

NM Updated by Nitzan Mordechai 4 months ago · Edited Actions #4

lets open new tracker for:

This is also quite unfortunate:

bash-5.1$ ceph crash ls
Error EIO: Module 'crash' has experienced an error and cannot handle commands: dictionary changed size during iteration
bash-5.1$ ceph crash archive-all
Error EIO: Module 'crash' has experienced an error and cannot handle commands: dictionary changed size during iteration

I assume this is due to the large amount of crashes (this is after about 24h)

its not related to the main issue

created: https://tracker.ceph.com/issues/79357

NM Updated by Nitzan Mordechai 4 months ago · Edited Actions #5

@virtualspark , thanks for the patch. I added some more code to guard against failures like that and also some self-tests

NM Updated by Nitzan Mordechai 4 months ago Actions #6

  • Pull request ID set to 70967

LF Updated by Laura Flores 4 months ago Actions #7

  • Copied to Backport #79396: umbrella: mgr: dispatch_remote() records a crash dump for NotImplementedError, so the documented orchestrator "ask for forgiveness" pattern pins RECENT_MGR_MODULE_CRASH forever added

LF Updated by Laura Flores 4 months ago Actions #8

  • Copied to Backport #79397: tentacle: mgr: dispatch_remote() records a crash dump for NotImplementedError, so the documented orchestrator "ask for forgiveness" pattern pins RECENT_MGR_MODULE_CRASH forever added

LF Updated by Laura Flores 4 months ago Actions #9

  • Tags (freeform) set to backport_processed

ST Updated by Satoru Takeuchi 4 months ago Actions #10

In my understanding, we can bypass this problem by disabling rook module. Is it correct?

NM Updated by Nitzan Mordechai 4 months ago Actions #11

Satoru Takeuchi wrote in #note-10:

In my understanding, we can bypass this problem by disabling rook module. Is it correct?

Correct, rook module returns the not implemented and is causing that issue.

UB Updated by Upkeep Bot 4 months ago Actions #12

  • Status changed from In Progress to Pending Backport
  • Merge Commit set to 5513ae2a1c25199e4fe57f4cf339a62e9ce0a5ee
  • Fixed In set to v21.3.0-1987-g5513ae2a1c
  • Upkeep Timestamp set to 2026-08-13T15:56:15+00:00

ST Updated by Satoru Takeuchi 4 months ago Actions #13

Correct, rook module returns the not implemented and is causing that issue.

Thank you very much!

NM Updated by Nitzan Mordechai 4 months ago Actions #14

  • Related to Bug #79357: Module 'crash' has experienced an error and cannot handle commands: dictionary changed size during iteration added

UB Updated by Upkeep Bot 3 months ago Actions #15

  • Status changed from Pending Backport to Resolved
  • Tags (freeform) deleted (backport_processed)
  • Upkeep Timestamp changed from 2026-08-13T15:56:15+00:00 to 2026-08-27T18:45:41+00:00
Actions

Also available in: PDF Atom