Venom1991 / refind-btrfs

Generate rEFInd manual boot stanzas from Btrfs snapshots
GNU General Public License v3.0
144 stars 8 forks source link

Missing "icon" option None check #23

Closed VulcanSphere closed 2 years ago

VulcanSphere commented 2 years ago

Hello there, I am unable to generate new boot entry with either systemd service or manually with refind-btrfs invocation which all ended in python crashing

Initializing the block devices using lsblk.
Initializing the physical partition table for device '/dev/nvme0n1' using lsblk.
Initializing the live partition table for device '/dev/nvme0n1' using findmnt.
Found the ESP mounted at '/boot/efi' on '/dev/nvme0n1p1'.
Found the root partition on '/dev/nvme0n1p3'.
Searching for snapshots of the '@' subvolume in the '/.snapshots' directory.
Found subvolume '@' mounted as the root partition.
Found 1 snapshot of the '@' subvolume.
Searching for the 'refind.conf' file on '/dev/nvme0n1p1'.
Found 1 boot stanza matched with the root partition.
Getting all snapshots in the '/root/.refind-btrfs' directory.
Initializing the static partition table for subvolume '@/.snapshots/1/snapshot' from its fstab file.
Found 1 snapshot for addition.
Found 4 snapshots for removal.
Creating a new writable snapshot from the read-only '@/.snapshots/1/snapshot' snapshot at '/root/.refind-btrfs/rwsnap_2021-11-10_00-26-32_ID2160'.
Modifying the '/root/.refind-btrfs/rwsnap_2021-11-10_00-26-32_ID2160/etc/fstab' file.
Deleting the '@/root/.refind-btrfs/rwsnap_2021-11-07_14-28-54_ID2002' snapshot.
Deleting the '@/root/.refind-btrfs/rwsnap_2021-11-09_15-06-25_ID2123' snapshot.
Deleting the '@/root/.refind-btrfs/rwsnap_2021-11-09_15-05-56_ID2122' snapshot.
Deleting the '@/root/.refind-btrfs/rwsnap_2021-11-07_14-31-29_ID2004' snapshot.
ERROR (refind_btrfs/__init__.py/main): An unexpected error happened, exiting...
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/refind_btrfs/__init__.py", line 80, in main
    exit_code = runner.run()
  File "/usr/lib/python3.9/site-packages/refind_btrfs/console/cli_runner.py", line 49, in run
    if not machine.run():
  File "/usr/lib/python3.9/site-packages/refind_btrfs/state_management/refind_btrfs_machine.py", line 102, in run
    while model.next_state():
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 401, in trigger
    return self.machine._process(func)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 1188, in _process
    return trigger()
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 426, in _trigger
    return self._process(event_data)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 435, in _process
    if trans.execute(event_data):
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 276, in execute
    self._change_state(event_data)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 286, in _change_state
    event_data.machine.get_state(self.dest).enter(event_data)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 128, in enter
    event_data.machine.callbacks(self.on_enter, event_data)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 1123, in callbacks
    self.callback(func, event_data)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 1144, in callback
    func(*event_data.args, **event_data.kwargs)
  File "/usr/lib/python3.9/site-packages/refind_btrfs/state_management/model.py", line 268, in process_changes
    self._process_boot_stanzas()
  File "/usr/lib/python3.9/site-packages/refind_btrfs/state_management/model.py", line 333, in _process_boot_stanzas
    for generated_refind_config in generated_refind_configs:
  File "/usr/lib/python3.9/site-packages/refind_btrfs/boot/refind_config.py", line 139, in generate_new_from
    migrated_boot_stanza = migration.migrate(
  File "/usr/lib/python3.9/site-packages/refind_btrfs/boot/migrations/migration.py", line 88, in migrate
    migration_result = boot_stanza_migration_strategy.migrate()
  File "/usr/lib/python3.9/site-packages/refind_btrfs/boot/migrations/main_migration_strategies.py", line 210, in migrate
    none_throws(current_state.icon_path),
  File "/usr/lib/python3.9/site-packages/refind_btrfs/utility/helpers.py", line 256, in none_throws
    raise AssertionError(message)
AssertionError: Unexpected 'None'

refind-btrfs.service

refind-btrfs.service - Generate rEFInd manual boot stanzas from Btrfs snapshots
     Loaded: loaded (/usr/lib/systemd/system/refind-btrfs.service; enabled; vendor preset: disabled)
     Active: active (running) since Wed 2021-11-10 00:34:34 WIB; 1s ago
   Main PID: 85078 (python)
      Tasks: 6 (limit: 8919)
     Memory: 29.5M
        CPU: 290ms
     CGroup: /system.slice/refind-btrfs.service
             └─85078 /usr/bin/python -m refind_btrfs --run-mode background

Nov 10 00:34:33 ako-kaede-mirai systemd[1]: Starting Generate rEFInd manual boot stanzas from Btrfs snapshots...
Nov 10 00:34:34 ako-kaede-mirai /usr/lib/python3.9/site-packages/refind_btrfs/__main__.py[85078]: Scheduling watch for directories: /.snapshots, /.snapshots/1.
Nov 10 00:34:34 ako-kaede-mirai /usr/lib/python3.9/site-packages/refind_btrfs/__main__.py[85078]: Starting the observer with PID 85078.
Nov 10 00:34:34 ako-kaede-mirai systemd[1]: Started Generate rEFInd manual boot stanzas from Btrfs snapshots.

refind.conf

menuentry "Arch Linux" {
    volume   6C725BB4-B057-5247-8CA2-661A34BB1CF7
    loader   /@/boot/vmlinuz-linux
    initrd   /@/boot/initramfs-linux.img
    options  "root=PARTUUID=6c725bb4-b057-5247-8ca2-661a34bb1cf7 rw rootflags=subvol=@ resume=PARTUUID=881a95dd-15ad-4296-bfbb-4abc579f361d ivrs_ioapic[4]=00:14.0 ivrs_ioapic[5]=00:00.1 nowatchdog lsm=landlock,lockdown,yama,selinux,bpf initrd=@\boot\amd-ucode.img initrd=@\boot\initramfs-linux.img"
    submenuentry "Boot using fallback initramfs" {
        initrd /@/boot/initramfs-linux-fallback.img
    }
    submenuentry "Boot to terminal" {
        add_options "systemd.unit=multi-user.target"
    }
Venom1991 commented 2 years ago

You're missing the "icon" option in your boot stanza: none_throws(current_state.icon_path)

Perhaps I could handle "None" values but it isn't currently implemented like that, as you can see.

VulcanSphere commented 2 years ago

Yup, it works now

Perhaps I could handle "None" values

Could be an idea for future enhancement I think

Venom1991 commented 2 years ago

Yeah, I'll simply add that check. The latest release obviously messed up this scenario, it's related to the custom icon feature.

Venom1991 commented 2 years ago

The "icon" option needn't exist in case the default icon generation mode is chosen.

Venom1991 commented 2 years ago

Fixed in the 0.4.2 release.