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).
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
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 --nowon ENI hot-attach/detach.This is undesirable for a few reasons:
/etc/systemd/system(e.g. NixOS).systemctl enable/disablecreates/deletes symlinks to systemd unit files elsewhere on the system (e.g./lib/systemd/system) in/etc/systemd/system.removeevent (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).Even without switching to systemd.device units, the udev rules should be doing
systemctl start/stopinstead ofsystemctl enable/disable.See NixOS/nixpkgs#355111 (comment) for a more detailed discussion.
Notes
BindsTo=can be used to tie units together (e.g. the policy refresh service and timer units).Requisite=).