nixos/kubo: fix potential panic on startup #272041
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes
This fixes a panic of the kubo daemon which could occur under certain conditions when the daemon was starting.
It was caused by the
ipfs.service
unit not depending on theipfs-api.socket
andipfs-gateway.socket
units withWants=
. This allows theipfs.service
to be started manually or bynixos-rebuild
without the sockets being set up before that. When that happens, the daemon won't know about these sockets and will only use what is set inservices.kubo.settings.Addresses.Gateway
andservices.kubo.settings.Addresses.API
. By default theAPI
is an empty list in NixOS though. The daemon doesn't like this at all and panics on startup, see ipfs/kubo#10056.With this commit, starting
ipfs.service
will first set up the two sockets before starting the actual service.Adding the
Sockets=
option implicitly adds aWants=
for the sockets and this is exactly what we need. See https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#Implicit%20Dependencies . This can be checked withsystemctl show ipfs.service
.This should probably be upstreamed to the unit file in the Kubo repo.
The problem can be reproduced in the following way:
services.kubo.enable = true
to/etc/nixos/configuration.nix
sudo nixos-rebuild switch
(this may already fail, not sure why it's not deterministic for me)sudo systemctl stop ipfs-api.socket
sudo systemctl stop ipfs-gateway.socket
sudo systemctl stop ipfs.service
sudo systemctl start ipfs.service
Fixes #248447.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.