Skip to content

mgr: forward the root-logger fallback at the record's own level - #70146

Merged
tchaikov merged 2 commits into
ceph:mainfrom
tchaikov:wip-mgr-logging-with-level
Jul 23, 2026
Merged

tchaikov merged 2 commits into
ceph:mainfrom
tchaikov:wip-mgr-logging-with-level

Conversation

@tchaikov

@tchaikov tchaikov commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

ceph_module.mgr_log() emitted every record at dout(0): a record either passed the Python-side gate and went unconditionally to both the log file and the in-memory recent buffer, or never reached the C++ log at
all. The two-level debug_mgr semantics (file level / memory level) never applied, so capturing third-party DEBUG logs meant sending each record to the log file and a log_max_recent slot; with the kubernetes client logging multi-megabyte HTTP response bodies at DEBUG, the recent buffer alone could grow to tens of gigabytes.

Pass the record's level through mgr_log() and emit at the mapped ceph level:

  • CRITICAL/ERROR at 0,
  • WARNING at 1,
  • INFO at 2,
  • DEBUG at 20. I

so it stays visible in the log file at the default debug_mgr=2/5; DEBUG maps to 20 so floods are dropped there, while debug_mgr=2/20 captures third-party DEBUG in the in-memory buffer without touching the log file. The Python-side gate follows the higher of the two debug_mgr levels so memory-only records still reach the C++ side.

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

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.

MgrRootHandler captures third-party logs from the Python root logger
and emits them through the _ceph_log method of whichever mgr module
last configured logging.  A handler on the root logger outlives any
single module, so once that module unloads the handler emits through
a stale pointer until another module reconfigures logging.

Add a free mgr_log() function to the ceph_module binding, emitting
via dout() like PyModuleRunner::log but with no PyModule involved,
and rewrite MgrRootHandler to route through it.  The handler no
longer references a module instance, so it cannot go stale.

Signed-off-by: Kefu Chai <[email protected]>
@tchaikov
tchaikov requested a review from a team as a code owner July 13, 2026 02:17
ceph_module.mgr_log() emitted every record at dout(0): a record either
passed the Python-side gate and went unconditionally to both the log
file and the in-memory recent buffer, or never reached the C++ log at
all.  The two-level debug_mgr semantics (file level / memory level)
never applied, so capturing third-party DEBUG logs meant sending each
record to the log file and a log_max_recent slot; with the kubernetes
client logging multi-megabyte HTTP response bodies at DEBUG, the
recent buffer alone could grow to tens of gigabytes.

Pass the record's level through mgr_log() and emit at the mapped ceph
level: CRITICAL/ERROR at 0, WARNING at 1, INFO at 2, DEBUG at 20.
INFO maps to 2 so it stays visible in the log file at the default
debug_mgr=2/5; DEBUG maps to 20 so floods are dropped there, while
debug_mgr=2/20 captures third-party DEBUG in the in-memory buffer
without touching the log file.  The Python-side gate follows the
higher of the two debug_mgr levels so memory-only records still
reach the C++ side.

Fixes: https://tracker.ceph.com/issues/77633
Signed-off-by: Kefu Chai <[email protected]>
@tchaikov
tchaikov force-pushed the wip-mgr-logging-with-level branch from 1530e07 to e61de15 Compare July 13, 2026 02:18
@tchaikov
tchaikov requested a review from mheler July 13, 2026 02:50
@tchaikov

Copy link
Copy Markdown
Contributor Author

@mheler hi Matthew, could you help review this change, i think we should step further and get the mgr a finer-grained python logging support.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by skanta started 2026-07-15-06:32.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by skanta started 2026-07-17-04:58.

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@tchaikov Since there is no tracker https://tracker.ceph.com/issues/77633 is already have another pr in it #70071 do we need new tracker for that PR? so we won't miss backports?
do we need a backport for other then Umbrella ?

@tchaikov

Copy link
Copy Markdown
Contributor Author

@NitzanMordhai hi Nitzan, thanks for your suggestion. indeed, it turns out #70071 helps with fixing the memleak, but that PR only touches the tip of the iceberg. the backport of https://tracker.ceph.com/issues/77538 's fix is the right minimal fix. but IMHO, this fix is a more elegant, but a more intrusive change. i created https://tracker.ceph.com/issues/78589 to track the "iceberg" tip fix. and leave https://tracker.ceph.com/issues/77633 for this PR.

@tchaikov
tchaikov merged commit a4c43f6 into ceph:main Jul 23, 2026
21 of 27 checks passed
@tchaikov
tchaikov deleted the wip-mgr-logging-with-level branch July 23, 2026 03:03
@NitzanMordhai

Copy link
Copy Markdown
Contributor

Thanks @tchaikov ! i think that the confusion was due to that line in the commit:
Fixes: https://tracker.ceph.com/issues/77633

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.

4 participants