Skip to content

Conversation

@trgill
Copy link
Collaborator

@trgill trgill commented Aug 28, 2025

This feature is only support on platforms that support snapshot manager (snapm)

Enhancement:

The bootable flag, when used with the snapm create command, creates a boot menu entry for the snapshot set. This allows the user to select the boot menu entry on reboot that will use the newly created snapshot set.

Result:

Support for bootable snapsets

Issue Tracker Tickets (Jira or BZ if any):

https://issues.redhat.com/browse/RHEL-106846

Summary by Sourcery

Add support for bootable LVM snapshots via a new snapshot_lvm_bootable flag and provide an experimental option to enable the snapm COPR repository.

New Features:

  • Introduce snapshot_lvm_bootable option to create boot menu entries for new snapshots on platforms with snapm support
  • Add experimental snapshot_use_copr option to enable the snapm COPR repository for development versions

Enhancements:

  • Propagate the bootable flag through module_utils and the snapshot Ansible module
  • Include enable_copr.yml task to configure the COPR repository when requested

Documentation:

  • Document snapshot_lvm_bootable and snapshot_use_copr variables in README

Tests:

  • Add integration tests for creating, verifying, and removing bootable snapshots with idempotence checks

@sourcery-ai
Copy link

sourcery-ai bot commented Aug 28, 2025

Reviewer's Guide

This PR introduces support for bootable LVM snapshots by adding a new snapshot_lvm_bootable flag (and experimental snapshot_use_copr option), propagating it through parameters, module utilities, tasks, and the snapshot library, updating documentation, and adding tests and conditional Copr repository setup.

Sequence diagram for bootable snapshot creation flow

sequenceDiagram
participant User as actor User
participant AnsiblePlaybook as Ansible Playbook
participant SnapshotModule as snapshot.py
participant LVMUtil as lvm.py
participant SnapMgrUtil as snapmgr.py
participant SnapManager as SnapManager
User->>AnsiblePlaybook: Run playbook with snapshot_lvm_bootable: true
AnsiblePlaybook->>SnapshotModule: Pass snapshot_lvm_bootable param
SnapshotModule->>LVMUtil: Build args with bootable flag
LVMUtil->>SnapMgrUtil: Pass bootable in snapset_json
SnapMgrUtil->>SnapManager: create_snapshot_set(..., boot=bootable)
SnapManager-->>SnapMgrUtil: Create snapshot and boot menu entry
SnapMgrUtil-->>LVMUtil: Return result
LVMUtil-->>SnapshotModule: Return result
SnapshotModule-->>AnsiblePlaybook: Return result
AnsiblePlaybook-->>User: Report snapshot and boot entry created
Loading

File-Level Changes

Change Details Files
Document new variables for bootable snapshots and Copr-enabled development versions
  • Add snapshot_lvm_bootable and snapshot_use_copr descriptions to README.md
README.md
Propagate the bootable parameter through module utilities to snapm calls
  • Extract bootable flag in snapmgr.create_snapshot_set call
  • Include bootable key in JSON builders in lvm and validate utilities
module_utils/snapshot_lsr/snapmgr.py
module_utils/snapshot_lsr/lvm.py
module_utils/snapshot_lsr/validate.py
Expose snapshot_lvm_bootable in the Ansible snapshot module interface
  • Define snapshot_lvm_bootable parameter in library/snapshot argument spec
  • Add nested bootable option in snapset dictionary
library/snapshot.py
Update role tasks for bootable snapshots and optional Copr repo
  • Include snapshot_lvm_bootable in snapshot module invocation
  • Add enable_copr task to conditionally enable Copr on Fedora
tasks/main.yml
tasks/enable_copr.yml
Add end-to-end tests for bootable snapshot workflows
  • Create tests_set_bootable.yml to validate create/check/remove idempotence with bootable flag
tests/tests_set_bootable.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@trgill trgill marked this pull request as ready for review September 3, 2025 00:37
@trgill trgill requested a review from spetrosi as a code owner September 3, 2025 00:37
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Duplicate extraction of the snapshot_lvm_bootable parameter in validate.py and lvm.py could be refactored into a shared helper to reduce code repetition.
  • The enable_copr task hardcodes the Copr repo URL—consider making that repository name/version configurable so it isn’t tied to a single Copr build.
  • Add an explicit platform guard or skip logic around the bootable flag to prevent invoking snapm boot options on hosts that don’t support snapshot manager.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Duplicate extraction of the snapshot_lvm_bootable parameter in validate.py and lvm.py could be refactored into a shared helper to reduce code repetition.
- The enable_copr task hardcodes the Copr repo URL—consider making that repository name/version configurable so it isn’t tied to a single Copr build.
- Add an explicit platform guard or skip logic around the bootable flag to prevent invoking snapm boot options on hosts that don’t support snapshot manager.

## Individual Comments

### Comment 1
<location> `tasks/enable_copr.yml:6` </location>
<code_context>
+- name: Enable snapm copr on Fedora
+  command: dnf -y copr enable packit/snapshotmanager-snapm-433
+  when: ansible_facts['distribution'] == 'Fedora'
+  changed_when: true
\ No newline at end of file
</code_context>

<issue_to_address>
Setting 'changed_when: true' may cause misleading change reporting.

This will always mark the task as changed, even if no action was needed. Use a more precise condition or a module that detects actual changes.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -10,6 +10,10 @@
use: "{{ (__snapshot_is_ostree | d(false)) |
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"

Copy link
Contributor

@richm richm Sep 4, 2025

Choose a reason for hiding this comment

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

There should be a task here to check the snapm version, and fail, or exit, if snapshot_lvm_bootable is true - for example, in the podman role, we do something similar to check if the user wants to use advanced features not available on some platforms - https://github.com/linux-system-roles/podman/blob/main/tasks/main.yml#L47-L79

  • install packages
  • get the snapm version - set the version in a global variable e.g. snapshot_snapm_version
  • if snapshot_lvm_bootable | d(false) and snapshot_snapm_version is version("<", "0.12") and snapshot_fail_if_too_old | d(true) - then use the fail: module to report failure
  • if snapshot_lvm_bootable | d(false) and snapshot_snapm_version is version("<", "0.12") and not snapshot_fail_if_too_old | d(true) - then use end_host: to skip the role without a failure

This:

  • lets the user of the role know that they are using an unsupported feature
  • allows the tests to pass when testing with an older version of snapm (by having the test set snapshot_fail_if_too_old: false)

@trgill trgill force-pushed the add_bootable branch 4 times, most recently from abd27c8 to 43d20a6 Compare September 16, 2025 23:53
@trgill
Copy link
Collaborator Author

trgill commented Sep 17, 2025

[citest]

@trgill
Copy link
Collaborator Author

trgill commented Oct 8, 2025

@richm snapm has been released with support for bootable snapsets. This is ready for review now.

@richm
Copy link
Contributor

richm commented Oct 10, 2025

[citest]

@trgill trgill force-pushed the add_bootable branch 2 times, most recently from 205010f to 54f1f44 Compare October 13, 2025 14:47
msg: >
This test is only supported on platforms with snapm support.
when:
- not __snapshot_snapm_available | d(false)
Copy link
Contributor

Choose a reason for hiding this comment

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

This test will always be skipped because __snapshot_snapm_available is not defined

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated the main.yml to check for:

when: snapshot_lvm_action is defined

to allow the role to be called to just set the variables.

Also, snapm version isn't yet updated on Fedora - so the bootable test will fail until that gets updated (should be this week I think).

This feature is only support on platforms that
support snapshot manager (snapm)

The bootable flag, when used with the snapm create
command, creates a boot menu entry for the snapshot
set. This allows the user to select the boot menu
entry on reboot that will use the newly created
snapshot set.

Signed-off-by: Todd Gill <[email protected]>
@richm
Copy link
Contributor

richm commented Oct 13, 2025

[citest]

@richm
Copy link
Contributor

richm commented Oct 14, 2025

I think you need some variable that tells if the platform supports bootable. tests_set_bootable.yml is failing on platforms where snapm is defined but the version is too old to support bootable.

@trgill
Copy link
Collaborator Author

trgill commented Oct 30, 2025

I think you need some variable that tells if the platform supports bootable. tests_set_bootable.yml is failing on platforms where snapm is defined but the version is too old to support bootable.

I've got the following:

- name: Package snapm version must be 0.5 or later bootable snapsets
  fail:
    msg: >
      Package snapm version {{ __snapshot_snapm_version }} is too old -
      must be 0.5 or later to use bootable snapsets
  when:
    - __snapshot_snapm_available
    - __snapshot_snapm_version is version("0.5", "<")
    - snapshot_lvm_bootable | d(false)

Currently 0.5.1 is recently released on Fedora. It should be available in RHEL and Centos soon.

Would it be reasonable to change to use:

ansible.builtin.meta: end_play

For example:

- name: Package snapm version must be 0.5 or later bootable snapsets
    msg: >
      Package snapm version {{ __snapshot_snapm_version }} is too old -
      must be 0.5 or later to use bootable snapsets
  when:
    - __snapshot_snapm_available
    - __snapshot_snapm_version is version("0.5", "<")
    - snapshot_lvm_bootable | d(false)
  
 - name: Stop play because snapm is too old
      ansible.builtin.meta: end_play
      when:
        - __snapshot_snapm_available
        - __snapshot_snapm_version is version("0.5", "<")
        - snapshot_lvm_bootable | d(false)

@richm
Copy link
Contributor

richm commented Nov 11, 2025

trgill#8

@richm
Copy link
Contributor

richm commented Nov 12, 2025

[citest]

@richm
Copy link
Contributor

richm commented Nov 12, 2025

[citest_bad]

@richm
Copy link
Contributor

richm commented Nov 12, 2025

[citest]

@richm
Copy link
Contributor

richm commented Nov 12, 2025

@trgill afaict, there is no problem in your code - the problem is that tests are not cleaning up which cause subsequent tests to fail - investigating

@richm
Copy link
Contributor

richm commented Nov 12, 2025

yep - cleanup - so on platforms where snapm is present but not the right version, we do end_host - the problem is that skips cleanup - so all of those volumes allocated in tasks/setup.yml are never cleaned

@richm
Copy link
Contributor

richm commented Nov 13, 2025

trgill#9

@richm
Copy link
Contributor

richm commented Nov 13, 2025

[citest]

@richm richm merged commit c37bf05 into linux-system-roles:main Nov 13, 2025
36 checks passed
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.

2 participants