Skip to content

systemd-boot-builder only ignores OSError "invalid argument"#206445

Merged
nlewo merged 1 commit intoNixOS:masterfrom
nlewo:ssytemd-boot-fail
Apr 16, 2023
Merged

systemd-boot-builder only ignores OSError "invalid argument"#206445
nlewo merged 1 commit intoNixOS:masterfrom
nlewo:ssytemd-boot-fail

Conversation

@nlewo
Copy link
Member

@nlewo nlewo commented Dec 16, 2022

In order to fix
#114552 (profile name with special characters), all OSError have been ignored while only the OSError with errno 22 (invalid argument) could has been ignored.

The drawback of ignoring all OSError is that the "No space left on device" error is also ignored. When the /boot doesn't have enough available disk space, the switch-to-configuration script succeeds while the boot menu has not been updated: the user thinks it's system has been updated, but on the next reboot it is actually rollbacked.

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Dec 16, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Dec 16, 2022
@RaitoBezarius
Copy link
Member

Could the test be even automated in nixos/tests/systemd-boot.nix ?

@nlewo
Copy link
Member Author

nlewo commented Apr 3, 2023

I hit this issue again and i have now been able to test this PR. Before the boot entries are not created and the script succeeds:

ignoring default profile in the list of boot entries because of the following error:
[Errno 28] No space left on device: '/nix/store/kxw13f32nw9hsy4nmfhrc4vj97mr5619-initrd-linux-5.15.94/initrd' -> '/boot/efi/nixos/kxw13f32nw9hsy4nmfhrc4vj97mr5619-initrd-linux-5.15.94-initrd.efi'
ignoring default profile in the list of boot entries because of the following error:
[Errno 28] No space left on device
ignoring default profile in the list of boot entries because of the following error:
[Errno 28] No space left on device: '/nix/store/4lqix0wdg2pbn1xqr1qi416bk4xi60ni-linux-5.15.104/bzImage' -> '/boot/efi/nixos/4lqix0wdg2pbn1xqr1qi416bk4xi60ni-linux-5.15.104-bzImage.efi'
ignoring default profile in the list of boot entries because of the following error:
[Errno 28] No space left on device: '/nix/store/mk7djkygw9xyv04xhxm0gy6p2h4gwd79-initrd-linux-5.15.104/initrd' -> '/boot/efi/nixos/mk7djkygw9xyv04xhxm0gy6p2h4gwd79-initrd-linux-5.15.104-initrd.efi'
ignoring default profile in the list of boot entries because of the following error:
[Errno 28] No space left on device
ignoring default profile in the list of boot entries because of the following error:
[Errno 28] No space left on device
ignoring default profile in the list of boot entries because of the following error:
[Errno 28] No space left on device
activating the configuration...
setting up /etc...

With this patch, it fails with:

Traceback (most recent call last):
  File "/nix/store/igngsnrm6anqm4hcqr79k0x50zg22gij-systemd-boot", line 319, in <module>
    main()
  File "/nix/store/igngsnrm6anqm4hcqr79k0x50zg22gij-systemd-boot", line 288, in main
    raise e
  File "/nix/store/igngsnrm6anqm4hcqr79k0x50zg22gij-systemd-boot", line 277, in main
    write_entry(*gen, machine_id)
  File "/nix/store/igngsnrm6anqm4hcqr79k0x50zg22gij-systemd-boot", line 110, in write_entry
    initrd = copy_from_profile(profile, generation, specialisation, "initrd")
  File "/nix/store/igngsnrm6anqm4hcqr79k0x50zg22gij-systemd-boot", line 83, in copy_from_profile
    copy_if_not_exists(store_file_path, "/boot%s" % (efi_file_path))
  File "/nix/store/igngsnrm6anqm4hcqr79k0x50zg22gij-systemd-boot", line 28, in copy_if_not_exists
    shutil.copyfile(source, dest)
  File "/nix/store/hhk4wr7hwry854sq69chmrjqyi964p7y-python3-3.10.9/lib/python3.10/shutil.py", line 267, in copyfile
    _fastcopy_sendfile(fsrc, fdst)
  File "/nix/store/hhk4wr7hwry854sq69chmrjqyi964p7y-python3-3.10.9/lib/python3.10/shutil.py", line 156, in _fastcopy_sendfile
    raise err from None
  File "/nix/store/hhk4wr7hwry854sq69chmrjqyi964p7y-python3-3.10.9/lib/python3.10/shutil.py", line 142, in _fastcopy_sendfile
    sent = os.sendfile(outfd, infd, offset, blocksize)
OSError: [Errno 28] No space left on device: '/nix/store/kxw13f32nw9hsy4nmfhrc4vj97mr5619-initrd-linux-5.15.94/initrd' -> '/boot/efi/nixos/kxw13f32nw9hsy4nmfhrc4vj97mr5619-initrd-linux-5.15.94-initrd.efi'

Could the test be even automated in nixos/tests/systemd-boot.nix ?

@RaitoBezarius I'm not able to find time to work on testing this part :( However, i think this patch improves the current situation where the switch-to-configuration script succeeds while the system won't be up to date on the next reboot...

@nlewo nlewo marked this pull request as ready for review April 3, 2023 19:22
@nlewo nlewo requested a review from dasJ as a code owner April 3, 2023 19:22
@nlewo nlewo force-pushed the ssytemd-boot-fail branch from d00338c to 98e20d1 Compare April 3, 2023 19:23
@RaitoBezarius
Copy link
Member

Agreed, I'm in favor of merging it as-is.

In order to fix
NixOS#114552 (profile name with
special characters), all OSError have been ignored while only the OSError
with errno 22 (invalid argument) could has been ignored.

The drawback of ignoring all OSError is that the "No space left on
device" error is also ignored. When the /boot doesn't have enough
available disk space, the switch-to-configuration script succeeds
while the boot menu has not been updated: the user thinks it's system
has been updated, but on the next reboot it is actually rollbacked.
@nlewo nlewo force-pushed the ssytemd-boot-fail branch from 98e20d1 to 2638fb7 Compare April 4, 2023 07:28
@nlewo nlewo merged commit ff24a05 into NixOS:master Apr 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants