Skip to content

common: add debug level guard to auto-revert high debug levels - #68442

Merged
SrinivasaBharath merged 1 commit into
ceph:mainfrom
lumir-sliva:wip-debug-level-guard
Sep 30, 2026
Merged

SrinivasaBharath merged 1 commit into
ceph:mainfrom
lumir-sliva:wip-debug-level-guard

Conversation

@lumir-sliva

@lumir-sliva lumir-sliva commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

High debug levels (e.g. debug_osd 20) set accidentally in production can cause catastrophic disk I/O floods and CPU overhead. This adds a guard that periodically checks subsystem debug levels and auto-reverts any that have been above a threshold for longer than a timeout.

What it does

  • New config: high_debug_level_threshold (default 0 = disabled) and high_debug_level_reset_timeout (default 300s, set to 0 for warn-only mode).
  • When any subsystem's log level hits the threshold, a HIGH_DEBUG_LEVEL mgr health warning surfaces in ceph health detail.
  • After the timeout, the guard sets the level back to what it was before it was raised, not the compiled default, so intentional customizations like debug_osd 1/5 are preserved.
  • Only the log level is checked, not the gather level. High gather levels are safe: those messages stay in memory for crash dumps and don't cause disk I/O.
  • Manual lower during the countdown cancels the pending revert.
  • Called from existing daemon tick paths (classic OSD, Monitor, Crimson OSD), zero hot-path overhead.
  • Disabled by default; must be explicitly enabled.

Example

$ ceph config set global high_debug_level_threshold 10
$ ceph config set global high_debug_level_reset_timeout 300
$ ceph tell osd.0 config set debug_osd 20
# within a few seconds:
$ ceph health detail
HEALTH_WARN 1 subsystems across 1 daemon(s) have high debug levels (max 20): osd.0
[WRN] HIGH_DEBUG_LEVEL: 1 subsystems across 1 daemon(s) have high debug levels (max 20): osd.0
# after 300s, in out/osd.0.log:
-1 Auto-reverted debug_osd from 20 to 1/5 after 300s (high_debug_level_threshold=10)

Tests

  • 9 GTest cases in test_debug_level_guard.cc: threshold disabled/active, warn-only, revert restores previous not default, manual-lower cancels revert, re-elevation resets timer, multiple subsystems tracked independently.
  • Integration workunit qa/workunits/mon/debug_level_guard.sh + teuthology suite entry under rados/singleton/all/, exercises a live cluster, verifies the health warning surfaces and clears.

Tested on vstart

End-to-end verified on a local vstart cluster (MON=1, MGR=1, OSD=1 and MON=1, MGR=1, OSD=3):

  • Elevated debug_bluestore from 1/5 to 25/25; health surfaced HIGH_DEBUG_LEVEL; auto-reverted to 1/5 after timeout; health cleared.
  • With reset_timeout=0 the warning persisted and no revert fired, warn-only mode works.
  • Manual lower during the countdown preserved the user's new value, confirming manual intent overrides the pending revert.
  • Verified both classic OSD and Monitor paths emit the HIGH_DEBUG_LEVEL metric through mgr.server handle_report daemon_health_metrics.

The two new config options (high_debug_level_threshold, high_debug_level_reset_timeout) are documented in doc/rados/troubleshooting/log-and-debug.rst, the HIGH_DEBUG_LEVEL health check in doc/rados/operations/health-checks.rst, and both in PendingReleaseNotes.

Tracker: https://tracker.ceph.com/issues/75467

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)

@lumir-sliva
lumir-sliva requested review from a team as code owners April 17, 2026 11:33
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

13 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@github-actions

github-actions Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

Config Diff Tool Output

+ added: high_debug_level_reset_timeout (global.yaml.in)
+ added: high_debug_level_threshold (global.yaml.in)

The above configuration changes are found in the PR. Please update the relevant release documentation if necessary.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@lumir-sliva

Copy link
Copy Markdown
Contributor Author

/config check ok

@lumir-sliva
lumir-sliva force-pushed the wip-debug-level-guard branch from 053237d to 8e6058a Compare April 17, 2026 11:59
@rzarzynski
rzarzynski self-requested a review April 20, 2026 17:53
@lumir-sliva

Copy link
Copy Markdown
Contributor Author

@ceph/core mind taking a look when you get a chance? Adds a debug level guard that auto-reverts a subsystem's debug level after a timeout, so an accidentally-bumped log level doesn't stay high forever. New common component with unit test + qa workunit. Rebased on current main, rebuilt clean (9/9 unit tests, ceph-mon/ceph-osd link fine); earlier red make check was a stale build env.

@lumir-sliva

Copy link
Copy Markdown
Contributor Author

@rzarzynski mind taking a look when you get a chance, or pointing me to the right person? (the @ceph/core mention above doesn't notify since I'm not in the org)

Comment thread qa/workunits/mon/debug_level_guard.sh Outdated
sleep 1
waited=$((waited + 1))
done
echo "Timed out waiting for $subsys on $daemon to revert below $threshold"

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.

- echo "Timed out waiting for $subsys on $daemon to revert below $threshold"
+ echo "ERROR: Timed out waiting for $subsys on $daemon to revert below $threshold"

Helps with debugging.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread qa/workunits/mon/debug_level_guard.sh Outdated
sleep 1
waited=$((waited + 1))
done
echo "Timed out waiting for $code in ceph health detail"

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.

Also add ERROR: here.

Applies to all other error messages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done for all three failure messages (wait_for_revert, wait_for_health_warning, wait_for_health_clear). The remaining checks are bare test calls under bash -ex, so the trace already shows which comparison failed.

Comment thread PendingReleaseNotes
Comment on lines +142 to +151
* RADOS: Added a debug-level guard that protects against accidentally leaving
debug subsystems at high log levels in production. When `high_debug_level_threshold`
is set (default `0` = disabled), any subsystem whose log level sits at or above
the threshold for longer than `high_debug_level_reset_timeout` seconds (default
`300`) is automatically reverted to the last known safe value, and a
`HIGH_DEBUG_LEVEL` health warning surfaces in `ceph health detail` while the
level remains elevated. Setting `high_debug_level_reset_timeout` to `0` gives
warn-only mode (health warning without auto-revert).
Related Tracker: https://tracker.ceph.com/issues/75467

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.

I would consider also adding this to the Documentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added docs in two places:

  • doc/rados/troubleshooting/log-and-debug.rst: new "Guarding Against High Debug Levels" section with confval entries for high_debug_level_threshold and high_debug_level_reset_timeout. Covers what it reverts to (last level below the threshold, compiled default if the daemon started high), that only the log level is checked, warn-only mode, and that the revert only changes the running value, so a level set with ceph config set needs a ceph config rm or it comes back on restart.
  • doc/rados/operations/health-checks.rst: HIGH_DEBUG_LEVEL entry under Miscellaneous, linking back to that section.

@ljflores ljflores 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.

Looks good! After the nit comments are addressed, I think this is ready to go into QA.

@ljflores

Copy link
Copy Markdown
Member

jenkins test api

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Sep 22, 2026
@lumir-sliva

Copy link
Copy Markdown
Contributor Author

still active

@github-actions github-actions Bot removed the stale label Sep 23, 2026
@lumir-sliva
lumir-sliva requested a review from a team as a code owner September 26, 2026 11:24
@lumir-sliva

Copy link
Copy Markdown
Contributor Author

@ljflores addressed your three comments and squashed into the single commit (1e3b0d2). No code changes, only the workunit messages and the new docs. Could you add needs-qa when you get a chance?

@anthonyeleven

Copy link
Copy Markdown
Contributor

Nice. What defines the last known safe level? Safety is relative.

@lumir-sliva

Copy link
Copy Markdown
Contributor Author

Nice. What defines the last known safe level? Safety is relative.

It's the last log/memory level the daemon had below high_debug_level_threshold, recorded on every tick (debug_level_guard.cc:42-44). If the daemon started already above the threshold, it's the compiled default (debug_level_guard.h:48-51).

We should maybe even drop the word, how about we say ... is automatically set back to the level it had before it was raised

long_desc: When a debug subsystem exceeds high_debug_level_threshold, the daemon sets it back to the level it had before it was raised, after this many seconds. ...

@anthonyeleven

Copy link
Copy Markdown
Contributor

Nice. What defines the last known safe level? Safety is relative.

It's the last log/memory level the daemon had below high_debug_level_threshold, recorded on every tick (debug_level_guard.cc:42-44). If the daemon started already above the threshold, it's the compiled default (debug_level_guard.h:48-51).

We should maybe even drop the word, how about we say ... is automatically set back to the level it had before it was raised

long_desc: When a debug subsystem exceeds high_debug_level_threshold, the daemon sets it back to the level it had before it was raised, after this many seconds. ...

I like that better. It says what the option does without promising more than we know. Is this stored in central config, or only runtime within the daemon? If the former we should be careful re cardinality or what happens if the new trim code removes a prior setting.

When debug levels are accidentally set too high (e.g., debug_osd 20),
they can cause catastrophic disk I/O floods and CPU overhead, leading
to service outages. This adds a DebugLevelGuard that periodically
checks subsystem debug levels and automatically reverts any that have
been above a configurable threshold for longer than a timeout.

New config options:
- high_debug_level_threshold (default: 0, disabled): log level at or
  above which the guard activates. When exceeded, a HIGH_DEBUG_LEVEL
  health warning is issued.
- high_debug_level_reset_timeout (default: 300s): seconds before an
  excessively high debug level is auto-reverted to its previous safe
  value. Set to 0 to disable auto-revert while keeping the health
  warning.

The guard is called from existing daemon tick functions (OSD, Monitor,
and Crimson OSD) with zero hot-path overhead. It only scans subsystem
levels once per tick interval. When reverting, it restores the last
known safe level rather than the compiled default, so intentional
customizations (e.g., debug_osd 1/5) are preserved.

Only the log level is checked, not the gather level. High gather
levels are safe because those messages stay in memory for crash dumps
and don't cause disk I/O.

The feature is disabled by default (threshold=0) and must be explicitly
enabled by setting high_debug_level_threshold to a non-zero value.

Includes unit tests (9 GTest cases) and integration test for
teuthology.

Tracker: https://tracker.ceph.com/issues/75467
Signed-off-by: Lumir Sliva <[email protected]>
@lumir-sliva

Copy link
Copy Markdown
Contributor Author

Is this stored in central config, or only runtime within the daemon?

Runtime only. The revert is a local set_val() in the daemon (ceph_context.cc:957), the same override ceph tell <daemon> config set uses. Nothing is written to the mon, so there are no config db or config-history entries for the trim to touch. The previous level is kept in daemon memory, one fixed entry per subsystem (debug_level_guard.h:102), so nothing grows.

One side effect: if the high level came from ceph config set, the override masks that option on the daemon until restart or ceph tell <daemon> config unset. Happy to add a line to the docs.

Pushed the wording change to both option descriptions and the release note.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath15-testing-20260929.043152-main.

@ljflores

Copy link
Copy Markdown
Member

RADOS approved: https://tracker.ceph.com/projects/rados/wiki/MAIN#httpstrackercephcomissues81091

@SrinivasaBharath
SrinivasaBharath merged commit d0a1e79 into ceph:main Sep 30, 2026
18 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/36787460356

@lumir-sliva

Copy link
Copy Markdown
Contributor Author

Amazing! Thank you everyone. We probably want to backport this to tentacle/umbrella ? It makes sense to me. I briefly checked and there are only 2 small conflicts in tentacle. Squid is not worth anymore.

Do you agree @ljflores @anthonyeleven or who decides in these cases?

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