Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After=network.target should be After=network-online.target #12724

Closed
udf2457 opened this issue Apr 22, 2024 · 2 comments · Fixed by #12741
Closed

After=network.target should be After=network-online.target #12724

udf2457 opened this issue Apr 22, 2024 · 2 comments · Fixed by #12741

Comments

@udf2457
Copy link

udf2457 commented Apr 22, 2024

In all your service files, After=network.target should be After=network-online.target.

Failure to do so will lead to flaky, unpredictable behaviour.

See man systemd.special, it says of network.target that:

This unit is supposed to indicate when network functionality is available, but it is only very weakly defined

And the rest of the man-page section about network.target basically appears to imply you should only rely on it during the shutdown process, not during boot.

Meanwhile the man systemd.special on network-online.target is pretty clear, e.g. :

Units that strictly require a configured network connection should pull in network-online.target (via a Wants= type dependency) and order themselves after it.

@chaudum
Copy link
Contributor

chaudum commented Apr 23, 2024

Thanks for pointing this out @udf2457

https://systemd.io/NETWORK_ONLINE/ even suggests to use

After=network-online.target
Wants=network-online.target

@udf2457
Copy link
Author

udf2457 commented Apr 23, 2024

@chaudum Regarding the suggestion, indeed.

After= is simply ordering, Wants= provides the actual hard-dependency.

So best practice in situations such as network-online is indeed to have both, because you actually want the actual hard-dependency for obvious reasons. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants