Skip to content

lvm2: add debug logging for all LVM2 command lines#994

Open
tasleson wants to merge 1 commit into
snapshotmanager:mainfrom
tasleson:lvm2_central_log
Open

lvm2: add debug logging for all LVM2 command lines#994
tasleson wants to merge 1 commit into
snapshotmanager:mainfrom
tasleson:lvm2_central_log

Conversation

@tasleson
Copy link
Copy Markdown
Contributor

@tasleson tasleson commented Apr 28, 2026

Introduce two new debug subsystems for LVM2 command tracing:

--debug=lvm2 Log every command line and its stdout on success.
--debug=lvm2err Log only commands that fail, with their stderr.

All logging is centralised in _Lvm2._run() so every subprocess invocation is covered. Command lines are formatted with shlex.join(). Both subsystems are included in --debug=all but can be enabled independently for fine-grained control.

Resolves: #979

Assisted-by: Claude noreply@anthropic.com

Summary by CodeRabbit

Release Notes

New Features

  • Added new LVM2-specific debug flags and logging subsystems for extended debugging capabilities
  • Extended debug support to include "lvm2" and "lvm2err" debug categories
  • Implemented automatic capture and logging of LVM2 command details including execution information, output, and error diagnostics

Introduce two new debug subsystems for LVM2 command tracing:

  --debug=lvm2     Log every command line and its stdout on success.
  --debug=lvm2err  Log only commands that fail, with their stderr.

All logging is centralised in _Lvm2._run() so every subprocess
invocation is covered. Command lines are formatted with shlex.join().
Both subsystems are included in --debug=all but can be enabled
independently for fine-grained control.

Resolves: snapshotmanager#979

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Tony Asleson <tasleson@redhat.com>
@packit-as-a-service
Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo dnf install -y 'dnf*-command(copr)'
  • dnf copr enable packit/snapshotmanager-snapm-994
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b222f729-ae9d-401a-940f-fe82e19cd5af

📥 Commits

Reviewing files that changed from the base of the PR and between 50e9872 and 05645ca.

📒 Files selected for processing (4)
  • snapm/_snapm.py
  • snapm/command.py
  • snapm/manager/plugins/lvm2.py
  • tests/test_command.py

Walkthrough

The pull request extends the debugging infrastructure by introducing two new debug mask flags (SNAPM_DEBUG_LVM2 and SNAPM_DEBUG_LVM2_ERR) and corresponding logging subsystems. These flags are wired into the command-line debug selector and used in the LVM2 plugin to emit debug logs for executed commands and captured error output.

Changes

Cohort / File(s) Summary
Debug Infrastructure
snapm/_snapm.py, snapm/command.py
Added constants SNAPM_DEBUG_LVM2, SNAPM_DEBUG_LVM2_ERR and subsystem names SNAPM_SUBSYSTEM_LVM2, SNAPM_SUBSYSTEM_LVM2_ERR; updated global debug mask and subsystem mapping; extended command-line debug selector to recognise "lvm2" and "lvm2err" options.
LVM2 Plugin Logging
snapm/manager/plugins/lvm2.py
Added module-level logger and debug logging in _Lvm2._run() to emit command-line strings on execution, decode and log stderr on errors, and conditionally emit failure details to "lvm2err" subsystem based on debug mask.
Test Updates
tests/test_command.py
Updated test_set_debug_list to include "lvm2" and "lvm2err" in the debug selector list assertion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

enhancement, Debugging, Plugin Integration

Poem

🐰 Hops with glee

New debug flags hop into view,
LVM2 commands now logged too,
When errors arise, they're captured with care,
A rabbit's delight—transparency everywhere! 🔍

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the primary change: adding debug logging for LVM2 command lines, which matches the core objective of centralising LVM2 command logging.
Linked Issues check ✅ Passed The pull request fully addresses issue #979 by implementing central debug logging for all LVM2 command lines in the _Lvm2._run() method, with controllable subsystems (--debug=lvm2 and --debug=lvm2err).
Out of Scope Changes check ✅ Passed All changes are within scope: new debug constants, debug subsystem support in command handling, logging implementation in lvm2.py, and corresponding test updates are all directly related to the central LVM2 debug logging objective.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lvm2: add central debug logging for LVM2 commands

1 participant