units: Shut down networkd and resolved on switch-root

Let's explicitly order these against initrd-switch-root.target, so
that they are properly shut down before we switch root. Otherwise,
there's a race condition where networkd might only shut down after
switching root and after we've already we've loaded the unit graph,
meaning it won't be restarted in the rootfs.

Fixes #27718
This commit is contained in:
Daan De Meyer 2023-05-25 18:13:02 +02:00 committed by Mike Yuan
parent 3d1e78e362
commit 75efd16fb0
2 changed files with 4 additions and 4 deletions

View file

@ -15,8 +15,8 @@ ConditionCapability=CAP_NET_ADMIN
DefaultDependencies=no
# systemd-udevd.service can be dropped once tuntap is moved to netlink
After=systemd-networkd.socket systemd-udevd.service network-pre.target systemd-sysusers.service systemd-sysctl.service
Before=network.target multi-user.target shutdown.target
Conflicts=shutdown.target
Before=network.target multi-user.target shutdown.target initrd-switch-root.target
Conflicts=shutdown.target initrd-switch-root.target
Wants=systemd-networkd.socket network.target
[Service]

View file

@ -16,8 +16,8 @@ Documentation=https://www.freedesktop.org/wiki/Software/systemd/writing-resolver
DefaultDependencies=no
After=systemd-sysusers.service
Before=sysinit.target network.target nss-lookup.target shutdown.target
Conflicts=shutdown.target
Before=sysinit.target network.target nss-lookup.target shutdown.target initrd-switch-root.target
Conflicts=shutdown.target initrd-switch-root.target
Wants=nss-lookup.target
[Service]