From 169bed877eed9e6928aad4d6f8acfa85076d5698 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 19 Mar 2021 09:39:17 +1100 Subject: [PATCH] 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 Change-Id: I1c9c68d3eb5fbeb42901f2ed95860641cb2d676f --- glean/init/nm-udev-settle.override | 3 +++ glean/install.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 glean/init/nm-udev-settle.override diff --git a/glean/init/nm-udev-settle.override b/glean/init/nm-udev-settle.override new file mode 100644 index 0000000..3b98f00 --- /dev/null +++ b/glean/init/nm-udev-settle.override @@ -0,0 +1,3 @@ +[Unit] +After=systemd-udev-settle.service +Wants=systemd-udev-settle.service diff --git a/glean/install.py b/glean/install.py index 5f64889..c24f66a 100755 --- a/glean/install.py +++ b/glean/install.py @@ -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@ 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')