Override NetworkManager to wait for udev-settle

As described inline, we think that NetworkManager is starting before
glean because the udev events have not been processed and the glean
services have not started.  Since there is nothing blocking it, the
network-pre.target is reached and systemd is free to start
NetworkManager.

Although it is not reccommended to wait on udev-settle because it
could result in long timeouts [1], I don't think we have a choice here
because the fundamental nature of this tool is to override settings
before NetworkManager goes off and does its own thing.

[1] https://www.freedesktop.org/software/systemd/man/systemd-udev-settle.service.html

Co-Authored-By: Dmitry Tantsur <dtantsur@protonmail.com>
Change-Id: I1c9c68d3eb5fbeb42901f2ed95860641cb2d676f
This commit is contained in:
Ian Wienand 2021-03-19 09:39:17 +11:00 committed by Dmitry Tantsur
parent 8dc38e4ae4
commit 169bed877e
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,3 @@
[Unit]
After=systemd-udev-settle.service
Wants=systemd-udev-settle.service

View File

@ -142,6 +142,23 @@ def main():
install('nm-no-resolv-handling.conf',
'/etc/NetworkManager/conf.d/nm-no-resolv-handling.conf',
mode='0644')
# NetworkManager has a "after" network-pre, and
# glean@<interface> services have a "before". However, if
# udev has not yet triggered and started the glean
# service, which it seems can be quite common in a slow
# environment like a binary-translated nested-vm, systemd
# may think it is fine to start NetworkManager because
# network-pre has been reached with no blockers. Thus we
# override NetworkManager to wait for udev-settle, which
# should ensure the glean service has started; which will
# block network-pre until it finishes writing out the
# configs.
install(
'nm-udev-settle.override',
'/etc/systemd/system/NetworkManager.service.d/override.conf',
mode='0644')
elif os.path.exists('/etc/init'):
log.info("Installing upstart services")
install('glean.conf', '/etc/init/glean.conf')