feat: add support for revertable snapshots with boot-time rollback capability#183
feat: add support for revertable snapshots with boot-time rollback capability#183trgill wants to merge 7 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughChangesAdds revertable snapshot parameters, snapm version and conflict handling, validation, workflow documentation, and Ansible integration tests covering creation, status, removal, and idempotence. Revertable snapshot workflow
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (4 passed)
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. Comment |
c7986f1 to
f3fd4f2
Compare
f3fd4f2 to
a395dac
Compare
a395dac to
6f2b5cf
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
README.md (1)
126-198: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the global configuration and conflict behavior.
The example only demonstrates per-set
revertable, while the new public variable issnapshot_lvm_revertable. Add a global-configuration example and explain how global and per-set values interact, including what happens when they conflict.As per path instructions,
README.mdmust document all new user-facing variables and include usage examples for new functionality.Also applies to: 335-351
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@README.md` around lines 126 - 198, The README’s revertable documentation omits the global snapshot_lvm_revertable setting and its precedence rules. Update the revertable configuration section and workflow examples to show how to enable it globally, document how global and per-set values interact, and explicitly describe the behavior when they conflict; ensure all new user-facing variables have usage examples.Source: Path instructions
tests/tests_set_revertable.yml (1)
63-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing idempotence check for the revertable creation step.
Unlike
tests/tests_basic_revertable.yml, which re-runs the snapshot creation step and assertsnot snapshot_cmd["changed"](lines 62-72 there), this file only checks idempotence for the remove action, not for the initial revertable creation. Per-set revertable creation idempotence is untested.♻️ Suggested addition mirroring tests_basic_revertable.yml
- name: Fail if not revertable assert: that: is_revertable + - name: Run the snapshot role again to check idempotence + include_tasks: tasks/run_role_with_clear_facts.yml + vars: + snapshot_lvm_action: snapshot + snapshot_lvm_revertable: true + snapshot_lvm_set: "{{ snapshot_test_set }}" + + - name: Assert no changes for create snapset idempotence + assert: + that: not snapshot_cmd["changed"] + - name: Remove the snapshot set🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/tests_set_revertable.yml` around lines 63 - 97, The revertable snapshot-set creation flow in tests_set_revertable.yml lacks an idempotence assertion. Re-run the existing snapshot creation task using the same snapshot_lvm_action, snapshot_lvm_revertable, and snapshot_lvm_set values, then assert that snapshot_cmd["changed"] is false before continuing to the snapset status checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@module_utils/snapshot_lsr/snapmgr.py`:
- Around line 254-257: Replace the truthiness checks for snapshot_lvm_revertable
with explicit None checks so provided False values are preserved. Apply this in
module_utils/snapshot_lsr/snapmgr.py lines 254-257 and
module_utils/snapshot_lsr/validate.py lines 39-41 and 347-349; also inspect
adjacent snapshot_lvm_bootable checks and apply the same correction only if they
exhibit the same omission-versus-False behavior.
In `@tests/tests_basic_revertable.yml`:
- Around line 41-84: Add verification after the revertable snapshot creation in
the test flow around “Assert changes for creation” by including the existing
get_snapset_status.yml task and asserting the returned snapset status has
is_revertable set. Mirror the established verification pattern from
tests_set_revertable.yml, while preserving the existing creation, idempotence,
and snapshot verification checks.
In `@tests/tests_set_revertable.yml`:
- Around line 98-104: The rescue matchers in tests/tests_set_revertable.yml
lines 98-104 and tests/tests_basic_revertable.yml lines 124-131 must match
revertable-specific snapm failures instead of bootable messages. Replace the
existing msg1/msg2 patterns in both rescues with patterns covering “Revertable
snapshots require snapm version %s or later” and “Revertable snapshots are not
supported without snapm”, preserving the current assertion structure.
---
Nitpick comments:
In `@README.md`:
- Around line 126-198: The README’s revertable documentation omits the global
snapshot_lvm_revertable setting and its precedence rules. Update the revertable
configuration section and workflow examples to show how to enable it globally,
document how global and per-set values interact, and explicitly describe the
behavior when they conflict; ensure all new user-facing variables have usage
examples.
In `@tests/tests_set_revertable.yml`:
- Around line 63-97: The revertable snapshot-set creation flow in
tests_set_revertable.yml lacks an idempotence assertion. Re-run the existing
snapshot creation task using the same snapshot_lvm_action,
snapshot_lvm_revertable, and snapshot_lvm_set values, then assert that
snapshot_cmd["changed"] is false before continuing to the snapset status checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f18c9105-5165-446e-a2ee-cb02899c33d3
📒 Files selected for processing (10)
.gitignoreREADME.mdlibrary/snapshot.pymodule_utils/snapshot_lsr/consts.pymodule_utils/snapshot_lsr/lvm.pymodule_utils/snapshot_lsr/snapmgr.pymodule_utils/snapshot_lsr/validate.pytests/get_snapset_status.ymltests/tests_basic_revertable.ymltests/tests_set_revertable.yml
b593ed8 to
027c1ab
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 126-143: Update the README sections documenting
snapshot_lvm_set.revertable and global snapshot_lvm_revertable to explicitly
describe their precedence and the validation behavior when both scopes are
configured inconsistently. Cover both configuration locations, state which value
takes effect, and document the conflict outcome supported by the implementation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 05d804bd-bdec-49f4-9887-ce6556d87743
📒 Files selected for processing (10)
.gitignoreREADME.mdlibrary/snapshot.pymodule_utils/snapshot_lsr/consts.pymodule_utils/snapshot_lsr/lvm.pymodule_utils/snapshot_lsr/snapmgr.pymodule_utils/snapshot_lsr/validate.pytests/get_snapset_status.ymltests/tests_basic_revertable.ymltests/tests_set_revertable.yml
🚧 Files skipped from review as they are similar to previous changes (9)
- module_utils/snapshot_lsr/consts.py
- .gitignore
- tests/tests_set_revertable.yml
- tests/tests_basic_revertable.yml
- tests/get_snapset_status.yml
- module_utils/snapshot_lsr/validate.py
- library/snapshot.py
- module_utils/snapshot_lsr/lvm.py
- module_utils/snapshot_lsr/snapmgr.py
c52d7f6 to
9b21a76
Compare
Add the snapshot_lvm_revertable parameter to the snapshot module, allowing users to create revert boot entries for snapshot sets. This parameter is supported at both the global level and within snapshot_lvm_set definitions. A revert boot entry allows booting into a special mode that automatically merges the snapshot back into the origin volume, providing a boot-time rollback mechanism for disaster recovery. Signed-off-by: Todd Gill <tgill@redhat.com>
Add support for creating revert boot entries when snapm is available. This allows users to boot into a special mode that automatically merges snapshots back into their origin volumes for disaster recovery. The revertable parameter now properly validates snapm availability and version support, failing explicitly rather than being silently ignored. Changes: - Add SNAPM_REVERT_PARAM_MIN_VERSION constant (0.5.0) - Add has_revert_parameter() version check function - Implement revertable parameter handling with conflict detection - Add explicit version validation for bootable and revertable features - Fail with ERROR_REVERTABLE_NOT_SUPPORTED when snapm is unavailable or version doesn't support revert parameter - Pass bootable/revert parameters to snapm create_snapshot_set via kwargs pattern for clean version-conditional support - Propagate revertable parameter through validation layer - Add ERROR_REVERTABLE_NOT_SUPPORTED and ERROR_REVERTABLE_CONFLICT status codes - Add debug logging for create_snapshot_set calls The implementation mirrors the existing bootable parameter handling, supporting both global-level and snapset-level configuration with conflict detection. Both parameters now validate properly instead of silently ignoring unsupported features. Signed-off-by: Todd Gill <tgill@redhat.com>
|
[citest] |
|
note that Testing Farm is having some issues, so it will be several hours before we get TF test results |
|
[citest] |
spetrosi
left a comment
There was a problem hiding this comment.
tests_set_revertable fails please take a look
| __pycache__/ | ||
| *~ | ||
| .pytest_cache/ | ||
| CLAUDE.md |
There was a problem hiding this comment.
Have you written your custom CLAUDE.md?
The role has a file .coderabbit.yaml with best-practices that CodeRabbit uses for review, and it can also be used for best-practices while developing. I wonder if creating a symlink from .coderabbit.yaml to CLAUDE.md would help?
There was a problem hiding this comment.
Or in CLAUDE.md, tell it to use the best-practices from .coderabbit.yaml
There was a problem hiding this comment.
yes, I wrote a CLAUDE.md - but it isn't polished. I was just giving claude tips for testing, naming conventions, python version compatability etc. It doesn't look like the other roles use it, so I added it to the .gitignore.
…hots Add comprehensive test coverage for the revertable snapshot feature: - tests_basic_revertable.yml: Test global snapshot_lvm_revertable parameter - tests_set_revertable.yml: Test revertable parameter in snapshot sets - Update get_snapset_status.yml to extract revert entry information Add documentation in README.md: - Document snapshot_lvm_revertable parameter and requirements - Add example showing bootable and revertable used together - Explain boot-time rollback mechanism Tests follow the existing bootable test patterns and include proper version checks and rescue blocks for older snapm versions. Signed-off-by: Todd Gill <tgill@redhat.com>
Signed-off-by: Todd Gill <tgill@redhat.com>
Update documentation to accurately explain how revertable snapshots work based on snapm behavior. The revert boot entry does NOT automatically perform a revert - users must first run the revert action, then boot into the revert entry. Changes: - Clarify snapshot_lvm_action: revert for revertable vs regular snapshots - Add explicit two-step process documentation with warnings - Add complete workflow example showing disaster recovery usage - Update snapshot_lvm_revertable parameter description - Emphasize that boot entry alone does not initiate revert This addresses confusion from snapshotmanager/snapm#999 where users expected automatic revert behavior from the boot entry alone. Signed-off-by: Todd Gill <tgill@redhat.com>
…ct handling Update documentation for both snapshot_lvm_bootable and snapshot_lvm_revertable to explicitly describe: - The two configuration locations (global vs. set-level) - Precedence rules (global takes precedence when set) - Conflict behavior (ERROR_BOOTABLE_CONFLICT or ERROR_REVERTABLE_CONFLICT) - That no snapshot is created when conflicting values are detected This addresses potential confusion about parameter precedence and makes it clear that conflicting values will cause the role to fail rather than silently choosing one value over the other. Signed-off-by: Todd Gill <tgill@redhat.com>
1a15854 to
5541be3
Compare
Fix boolean parameter checking to distinguish between explicit False and
unset (None) values. Previously, truthy checks treated False the same as
None, causing silent conflicts when:
- Global parameter set to False
- Set-level parameter set to True
The global False was silently ignored instead of raising a conflict error.
Changes:
- Use `module_args.get("param") is not None` instead of `if module_args["param"]:`
- Applies to both snapshot_lvm_bootable and snapshot_lvm_revertable
- Fixed in snapmgr.py (conflict detection) and validate.py (parameter propagation)
This ensures ERROR_BOOTABLE_CONFLICT and ERROR_REVERTABLE_CONFLICT are
correctly raised for all conflicting configurations, not just when the
global value is True.
Signed-off-by: Todd Gill <tgill@redhat.com>
5541be3 to
23fb519
Compare
|
[citest] |
Enhancement:
Add support for revertable snapshots with boot-time rollback capability. This feature allows users to create snapshot sets with revert boot menu entries, enabling disaster recovery scenarios where the system can be rolled back to a previous state by first running the revert action and then booting into the revert entry.
Reason:
System administrators need a reliable disaster recovery mechanism for critical operations like system upgrades or configuration changes. The existing bootable snapshot feature allows booting into a snapshot, but does not provide a way to permanently revert the system to that snapshot state. Revertable snapshots fill this gap by providing a two-step process to merge snapshots back into their origin volumes, effectively rolling back the system to the snapshot point-in-time.
Result:
snapshot_lvm_revertableparameter (boolean, default false) that can be set globally or per snapshot setsnapshot_lvm_revertable: trueto generate revert boot entriessnapshot_lvm_action: revertto initiate the revert operationtests_basic_revertable.ymlandtests_set_revertable.ymlbootablefeature, supporting both global and per-set configuration with conflict detectionIssue Tracker Tickets (Jira or BZ if any):
Related to snapshotmanager/snapm#999 (clarification of revertable behavior)
Summary by CodeRabbit
snapshot_lvm_revertable) and per set (revertable) controls.CLAUDE.md.