You are not logged in.

#1 2012-11-01 11:12:31

MisterAnderson
Member
Registered: 2011-09-04
Posts: 284

systemd services seem to ignore "After=network.target" with NM

Hey, I've been having some trouble with services that require the network to be up running too early in the boot sequence. I'm running NetworkManager.

Looking at the journal shows them running before networkmanager starts the interfaces, and failing since there's no interface available yet.

For now I've discovered that running "systemctl enable NetworkManager-wait-online.service" seems to have solved it, but is this how it is supposed to work or is something going wrong?


D:

Offline

#2 2012-11-01 16:54:20

Stebalien
Member
Registered: 2010-04-27
Posts: 1,227
Website

Re: systemd services seem to ignore "After=network.target" with NM

For now, yes. 'network.target' is mostly for compatibility with sysvinit and is fundamentally broken for systems that have intermittent internet connections. If you have services must only be running when the network is up, you can use network manager's dispatcher. Even better, create an 'online.target' unit and start/stop this with network manager's dispatcher.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

#3 2012-11-01 21:36:15

tomegun
Developer
From: France
Registered: 2010-05-28
Posts: 661

Re: systemd services seem to ignore "After=network.target" with NM

MisterAnderson wrote:

For now I've discovered that running "systemctl enable NetworkManager-wait-online.service" seems to have solved it, but is this how it is supposed to work or is something going wrong?

It is intentional, by NM upstream. By default network.target is reached when NM has finished initializing. If you want it to wait for the network to be "up" (whatever that means, as it is not really clear) you should enable wait-online, as you did.

Offline

#4 2012-11-04 18:31:53

MisterAnderson
Member
Registered: 2011-09-04
Posts: 284

Re: systemd services seem to ignore "After=network.target" with NM

I'm just wondering what the point of network.target is in the first place if it doesn't force units with after=network.target to wait until the interfaces are ready. I mean I can understand not waiting for a real connection to some form of network, but at the very least shouldn't the interfaces at least be named by then?


D:

Offline

#5 2012-11-05 18:02:50

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 949

Re: systemd services seem to ignore "After=network.target" with NM

MisterAnderson wrote:

I'm just wondering what the point of network.target is in the first place if it doesn't force units with after=network.target to wait until the interfaces are ready. I mean I can understand not waiting for a real connection to some form of network, but at the very least shouldn't the interfaces at least be named by then?

Can you post the logs then? The NM/netcfg/... service is supposed to exit only when low-level devices are initialized properly, no?


Arch Linux is more than just GNU/Linux -- it's an adventure

Offline

#6 2012-11-06 11:14:41

MisterAnderson
Member
Registered: 2011-09-04
Posts: 284

Re: systemd services seem to ignore "After=network.target" with NM

The service isn't exiting, it's that other services are starting whilst NetworkManager is starting, so the interfaces are initialised and named yet. After=network.target appears to only make other services wait until NetworkManager starts, not until it's finished.


D:

Offline

#7 2012-11-06 21:34:51

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 949

Re: systemd services seem to ignore "After=network.target" with NM

MisterAnderson wrote:

The service isn't exiting, it's that other services are starting whilst NetworkManager is starting, so the interfaces are initialised and named yet. After=network.target appears to only make other services wait until NetworkManager starts, not until it's finished.

OK. I guess the problem is that NM.service is Type=dbus. so systemd doesn't wait on it to finish but only for the dbus socket to appear (?). That's why you have to insert an additional ordering point NM-online.service which delays the start of network.target. I wonder though if you can avoid that by using type-forking and removing "--no-daemon" argument...


Arch Linux is more than just GNU/Linux -- it's an adventure

Offline

#8 2012-11-11 23:03:14

scales
Member
Registered: 2008-07-16
Posts: 22

Re: systemd services seem to ignore "After=network.target" with NM

I am having this problem with a fresh install and I use the net-auto-wired.service

Was this ever fixed?

Offline

#9 2012-11-15 15:48:51

MisterAnderson
Member
Registered: 2011-09-04
Posts: 284

Re: systemd services seem to ignore "After=network.target" with NM

I don't see what you're asking, you're not even using networkmanager.


D:

Offline

#10 2013-03-04 12:27:11

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: systemd services seem to ignore "After=network.target" with NM

Hello,

I enabled the NetworkManager-wait-online.service in order to let my programs such as Dropbox, Insync or Crashplan connect in cases when my internet connection is not available immediately after boot.

However, I receive the following error log in journalctl -b:

NetworkManager-wait-online.service: main process exited, code=exited, status=1/FAILURE
Failed to start Network Manager Wait Online
Unit NetworkManger-wait-online.service entered failed state
Starting Network.
Reached target Network.

Does someone have a clue why it is not working?

Offline

#11 2013-03-12 10:02:25

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: systemd services seem to ignore "After=network.target" with NM

The problem is related to the default timeout of 30 in the service being too low. Change 30 to something higher in /usr/lib/systemd/system/NetworkManager-wait-online.service.

Last edited by orschiro (2013-03-12 10:02:39)

Offline

Board footer

Powered by FluxBB