Bring up glean before network.service

We had a problem with nodepool and RAX where we weren't bringing the
network up fast enough because eth0 was waiting around for a DHCP
response (that would never come) before glean got started to configure
the interface.  This seems to be because network.service was started
first, and defaulted to trying to bring up the interface with DHCP.

The whole ordering of systemd is a bit of a black art.  Reading [1]
says

  network-pre.target is a target that may be used to order services
  before any network interface is configured. It's primary purpose is
  for usage with firewall services that want to establish a firewall
  before any network interface is up. It's a passive unit: you cannot
  start it directly and it is not pulled in by the the network
  management service, but by the service that wants to run before
  it. Network management services hence should set
  After=network-pre.target, but avoid any Wants=network-pre.target or
  even Requires=network-pre.target. Services that want to be run
  before the network is configured should place
  Before=network-pre.target and also set Wants=network-pre.target to
  pull it in. This way, unless there's actually a service that needs
  to be ordered before the network is up the target is not pulled in,
  hence avoiding any unnecessary synchronization point.

So we're not a firewall, but it seems like we fit that model of
wanting to configure the interface from config-drive.  So, as it
suggests use the "Wants" and "Before" to get the glean service to run
before we try to enable the network.

(We probably don't actually need the After=network.target in their
either.  You can read on [1] that is mostly for shutdown-ordering, so
is not relevant to glean, but it doesn't hurt)

Honestly, the relationship between udev, systemd service-unit
templates, network.service and ifup/ifdown is pretty uncharted
territory.  But we tried this with
Ib9d7cc711186299c77795e5147bf332c56e3aa7c and the centos-minimal node
booted and nodepool connected to it fine.

Change-Id: I066c0c89a30280af9d7a5d8d1a916daeddc84fa3
This commit is contained in:
Ian Wienand 2016-03-17 16:41:54 +11:00 committed by Paul Belanger
parent 37891a713c
commit 19dd973159
1 changed files with 3 additions and 1 deletions

View File

@ -1,6 +1,8 @@
[Unit]
Description=Glean for interface %I
After=network.service network.target
After=network.target
Before=network-pre.target
Wants=network-pre.target
ConditionPathExists=!/etc/sysconfig/network-scripts/ifcfg-%I