Open
Description
Description
systemd supports device units (systemd.device) which are dynamically created/deleted/reloaded on device hot-attach/hot-detach/change.
Update the udev rules and systemd unit files to use this instead of systemctl enable
/disable
.
Background
The current udev rules create/delete + start/stop systemd units by running systemctl enable
/disable --now
on ENI hot-attach/detach.
This is undesirable for a few reasons:
- It doesn't work in distributions with an immutable
/etc/systemd/system
(e.g. NixOS).systemctl enable
/disable
creates/deletes symlinks to systemd unit files elsewhere on the system (e.g./lib/systemd/system
) in/etc/systemd/system
.
- Interface-specific units are started automatically on reboot by systemd without input from udev.
- If an instance is stopped, an ENI is detached, and the instance is started, there may be zombie service and timer units until udev emits a
remove
event (if it does it at all. It might not if there's a power outage or the system crashes and the ENI is removed before the subsequent boot).
- If an instance is stopped, an ENI is detached, and the instance is started, there may be zombie service and timer units until udev emits a
Even without switching to systemd.device units, the udev rules should be doing systemctl start
/stop
instead of systemctl enable
/disable
.
See NixOS/nixpkgs#355111 (comment) for a more detailed discussion.
Notes
- The udev remove rule should also have the systemd tag to ensure device units are removed on hot-detach (USB device still active even after physically unplugged systemd/systemd#7587 (comment)).
BindsTo=
can be used to tie units together (e.g. the policy refresh service and timer units).- Package should use systemd presets instead of enabling/disabling services #102 talks about using systemd presets (systemd.preset) instead, primarily to express that systemd-networkd should be used over NetworkManager.
- This complects management of the network daemon with installing the systemd units. The systemd units should just gracefully not start or do a no-op if systemd-networkd isn't active (e.g. use
Requisite=
).
- This complects management of the network daemon with installing the systemd units. The systemd units should just gracefully not start or do a no-op if systemd-networkd isn't active (e.g. use
Metadata
Assignees
Labels
No labels
Activity