Skip to content

boot: handle swap entries in /etc/fstab#537

Merged
bmr-cymru merged 3 commits intomainfrom
bmr-swaps-as-swaps
Oct 16, 2025
Merged

boot: handle swap entries in /etc/fstab#537
bmr-cymru merged 3 commits intomainfrom
bmr-swaps-as-swaps

Conversation

@bmr-cymru
Copy link
Copy Markdown
Contributor

@bmr-cymru bmr-cymru commented Oct 16, 2025

Handle swap entries in /etc/fstab explicitly, rather than punting them to boom.command.create_entry(mounts=...) to DTRT.

Resolves: #532
Resolves: #533
Resolves: #534
Resolves: #535

Summary by CodeRabbit

  • New Features

    • Boot entries now include detected swap specifications from system configuration so swap is preserved across boot setups.
    • Creation of boot entries accepts an optional list of swap specifications to ensure swap is recorded when entries are created.
  • Bug Fixes

    • Swap entries are no longer treated as mounts.
    • Malformed configuration lines are ignored to prevent incorrect boot entries.

Resolves: #533
Related: #532

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
@bmr-cymru bmr-cymru self-assigned this Oct 16, 2025
@bmr-cymru bmr-cymru added the Bug Something isn't working label Oct 16, 2025
@bmr-cymru bmr-cymru added Enhancement New feature or request UI/UX User interface and experience Boot Boot integration problems labels Oct 16, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 16, 2025

Walkthrough

Parse /etc/fstab to extract swap entries separately, avoid treating swap lines as mounts, pass the swap list into boom.command.create_entry, and adjust internal function signatures to accept an optional swaps parameter.

Changes

Cohort / File(s) Summary
Boot entry swap handling
snapm/manager/_boot.py
Added _build_swap_list() to parse /etc/fstab and collect swap entries as "WHAT:OPTIONS"; updated _build_snapset_mount_list() to skip swap-type and malformed lines; changed _create_boom_boot_entry() signature to accept swaps=None and forward swaps to boom.command.create_entry(); create_snapset_boot_entry() now computes and passes swaps.

Sequence Diagram(s)

sequenceDiagram
    participant Creator as create_snapset_boot_entry()
    participant Mounts as _build_snapset_mount_list()
    participant Swaps as _build_swap_list()
    participant Maker as _create_boom_boot_entry()
    participant Boom as boom.command.create_entry()

    Creator->>Mounts: Read /etc/fstab (skip swap & malformed)
    Mounts-->>Creator: mounts[]
    Creator->>Swaps: Read /etc/fstab (collect swap entries)
    Swaps-->>Creator: swaps[] ("WHAT:OPTIONS")
    Creator->>Maker: Pass version,title,tag_arg,root_device,mounts,swaps
    Maker->>Boom: create_entry(mounts=..., swaps=...)
    Boom-->>Maker: boot_entry
    Maker-->>Creator: boot_entry
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐰
I sniffed through fstab, gentle and quick,
Pulled swaps aside with a tidy flick,
Mounts stay honest, no "none" to see,
Snapsets boot smarter — hop with me!

Pre-merge checks and finishing touches

✅ 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 clearly and concisely describes the main change of explicitly handling swap entries in /etc/fstab, which is the core focus of the modifications in the _boot.py file.
Linked Issues Check ✅ Passed The pull request adds a function to build a separate swap list fulfilling issue #534, updates the mount list builder to exclude swap entries and prevent the “Invalid mount point: none” error of issue #532 and excludes swaps from mounts as per issue #533, and passes swaps via the swaps parameter to boom.command.create_entry addressing issue #535.
Out of Scope Changes Check ✅ Passed All modifications are confined to the _boot.py module and directly support the objectives related to swap entry handling; there are no unrelated or extraneous changes present in the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bmr-swaps-as-swaps

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 705a7bb and 2453926.

📒 Files selected for processing (1)
  • snapm/manager/_boot.py (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • snapm/manager/_boot.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (45)
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: virt_tests (uefi, lvm, fedora41)
  • GitHub Check: virt_tests (bios, lvm, fedora42)
  • GitHub Check: virt_tests (bios, lvm-thin, centos-stream9)
  • GitHub Check: virt_tests (bios, lvm, fedora41)
  • GitHub Check: virt_tests (uefi, lvm-thin, centos-stream10)
  • GitHub Check: virt_tests (uefi, lvm-thin, centos-stream9)
  • GitHub Check: virt_tests (uefi, lvm-thin, fedora42)
  • GitHub Check: virt_tests (uefi, lvm-thin, fedora41)
  • GitHub Check: virt_tests (bios, lvm, centos-stream9)
  • GitHub Check: virt_tests (uefi, lvm, centos-stream10)
  • GitHub Check: virt_tests (uefi, lvm, fedora42)
  • GitHub Check: virt_tests (uefi, lvm, centos-stream9)
  • GitHub Check: virt_tests (bios, lvm, centos-stream10)
  • GitHub Check: virt_tests (bios, lvm-thin, fedora41)
  • GitHub Check: virt_tests (bios, lvm-thin, centos-stream10)
  • GitHub Check: virt_tests (bios, lvm-thin, fedora42)
  • GitHub Check: python-basic-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.

@bmr-cymru bmr-cymru changed the title boot: handle swap entries in /etc/fstab boot: handle swap entries in /etc/fstab Oct 16, 2025
@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 yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/snapshotmanager-snapm-537
  • And now you can install the packages.

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
snapm/manager/_boot.py (1)

371-387: Document the new swaps parameter.

The function signature now includes a swaps parameter, but the docstring doesn't describe it. Please add documentation for this parameter to maintain API clarity.

Apply this diff to update the docstring:

 def _create_boom_boot_entry(
     version, title, tag_arg, root_device, mounts=None, swaps=None
 ):
     """
     Create a boom boot entry according to the passed arguments.
 
     :param version: The UTS release name for the boot entry
     :param title: The title for the boot entry.
     :param tag_arg: A tag argument to be added to the kernel command line and
                     used to associate the entry with a snapshot set name or
                     UUID.
     :param root_device: The root device for the entry. Passed to root=...
     :param lvm_root_lv: An optional LVM2 root logical volume.
     :param mounts: An optional list of mount specifications to use for the
                    boot entry. If defined fstab=no will be appended to the
                    generated kernel command line.
+    :param swaps: An optional list of swap specifications to use for the
+                  boot entry. Each entry should be in the format "WHAT:OPTIONS".
     """
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b73d3f9 and 4409fb8.

📒 Files selected for processing (1)
  • snapm/manager/_boot.py (4 hunks)
🧰 Additional context used
🪛 Ruff (0.14.0)
snapm/manager/_boot.py

364-364: Unpacked variable where is never used

Prefix it with an underscore or any other dummy variable pattern

(RUF059)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (30)
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: virt_tests (uefi, lvm-thin, centos-stream10)
  • GitHub Check: virt_tests (uefi, lvm-thin, fedora42)
  • GitHub Check: virt_tests (uefi, lvm-thin, centos-stream9)
  • GitHub Check: virt_tests (uefi, lvm, centos-stream10)
  • GitHub Check: virt_tests (bios, lvm, fedora41)
  • GitHub Check: virt_tests (uefi, lvm, fedora41)
  • GitHub Check: virt_tests (bios, lvm-thin, fedora42)
  • GitHub Check: virt_tests (bios, lvm-thin, fedora41)
  • GitHub Check: virt_tests (bios, lvm, centos-stream10)
  • GitHub Check: virt_tests (uefi, lvm-thin, fedora41)
  • GitHub Check: virt_tests (bios, lvm, centos-stream9)
  • GitHub Check: virt_tests (uefi, lvm, centos-stream9)
  • GitHub Check: virt_tests (uefi, lvm, fedora42)
  • GitHub Check: virt_tests (bios, lvm, fedora42)
  • GitHub Check: virt_tests (bios, lvm-thin, centos-stream10)
  • GitHub Check: virt_tests (bios, lvm-thin, centos-stream9)
🔇 Additional comments (4)
snapm/manager/_boot.py (4)

343-343: LGTM! Correctly excludes swap entries from the mount list.

The modification appropriately filters out swap-type entries, preventing them from being treated as filesystem mounts. This directly addresses issue #533.


423-423: LGTM! Correctly passes swap definitions to boom.

The swap list is now properly passed to boom.command.create_entry via the swaps parameter, addressing issue #535.


452-452: LGTM! Properly retrieves swap definitions.

Swap entries are correctly extracted from /etc/fstab before creating the boot entry. Ensure the error handling suggestions for _build_swap_list() are addressed.


459-459: LGTM! Completes the swap handling flow.

The swap definitions are correctly passed through to the boot entry creation function, ensuring swap configurations are included in the generated boot entry.

Comment thread snapm/manager/_boot.py
@bmr-cymru bmr-cymru moved this to In Progress in Bug Fixes Oct 16, 2025
Comment thread snapm/manager/_boot.py
Resolves: #534
Resolves: #535
Resolves: #532

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
coderabbitai[bot]
coderabbitai Bot previously requested changes Oct 16, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
snapm/manager/_boot.py (1)

391-391: Remove stale parameter from docstring.

The docstring references an lvm_root_lv parameter that does not exist in the function signature. This appears to be outdated documentation.

Apply this diff:

     :param root_device: The root device for the entry. Passed to root=...
-    :param lvm_root_lv: An optional LVM2 root logical volume.
     :param mounts: An optional list of mount specifications to use for the
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4409fb8 and 705a7bb.

📒 Files selected for processing (1)
  • snapm/manager/_boot.py (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
snapm/manager/_boot.py (1)
snapm/manager/plugins/_plugin.py (1)
  • _log_warn (92-96)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (29)
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:centos-stream-9-x86_64
  • GitHub Check: rpm-build:fedora-43-x86_64
  • GitHub Check: rpm-build:fedora-rawhide-x86_64
  • GitHub Check: rpm-build:fedora-41-x86_64
  • GitHub Check: rpm-build:centos-stream-10-x86_64
  • GitHub Check: rpm-build:fedora-42-x86_64
  • GitHub Check: rpm-build:epel-9-x86_64
  • GitHub Check: virt_tests (bios, lvm, centos-stream9)
  • GitHub Check: virt_tests (uefi, lvm-thin, fedora42)
  • GitHub Check: virt_tests (uefi, lvm, centos-stream10)
  • GitHub Check: virt_tests (bios, lvm, fedora41)
  • GitHub Check: virt_tests (bios, lvm-thin, centos-stream10)
  • GitHub Check: virt_tests (bios, lvm, centos-stream10)
  • GitHub Check: virt_tests (uefi, lvm, fedora41)
  • GitHub Check: virt_tests (uefi, lvm, centos-stream9)
  • GitHub Check: virt_tests (uefi, lvm-thin, fedora41)
  • GitHub Check: virt_tests (bios, lvm-thin, fedora42)
  • GitHub Check: virt_tests (bios, lvm-thin, centos-stream9)
  • GitHub Check: virt_tests (bios, lvm-thin, fedora41)
  • GitHub Check: virt_tests (bios, lvm, fedora42)
  • GitHub Check: virt_tests (uefi, lvm-thin, centos-stream10)
  • GitHub Check: virt_tests (uefi, lvm-thin, centos-stream9)
  • GitHub Check: virt_tests (uefi, lvm, fedora42)
  • GitHub Check: python-basic-tests
🔇 Additional comments (3)
snapm/manager/_boot.py (3)

342-347: LGTM! Swap exclusion and validation logic implemented correctly.

The added validation for malformed fstab lines and explicit exclusion of swap entries align with the PR objectives and address issues #533 and #535.


462-462: LGTM! Swap list integration implemented correctly.

The integration correctly calls _build_swap_list() to obtain swap entries and passes them to _create_boom_boot_entry() via the new swaps parameter. This properly separates swap handling from mount handling, addressing PR objectives #532, #533, and #535.

Also applies to: 469-469


379-381: Verify external boom.command.create_entry API

  • Confirm that the external boom.command.create_entry function accepts a swaps parameter.
  • Remove the stale lvm_root_lv reference from the function docstring (lines 395–396).

Comment thread snapm/manager/_boot.py
Related: #375

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
@bmr-cymru bmr-cymru dismissed coderabbitai[bot]’s stale review October 16, 2025 17:22

It's better to have a hard & immediate failure than to try to continue operating with a missing /etc/fstab. Propagating the error and logging it is the appropriate action for now.

@bmr-cymru bmr-cymru merged commit 2453926 into main Oct 16, 2025
30 of 31 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Bug Fixes Oct 16, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Oct 17, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Nov 2, 2025
@bmr-cymru bmr-cymru deleted the bmr-swaps-as-swaps branch November 10, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Boot Boot integration problems Bug Something isn't working Enhancement New feature or request UI/UX User interface and experience

Projects

Status: Done

1 participant