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

Add Wants=network-online.target #572

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

arianvp
Copy link

@arianvp arianvp commented Jun 10, 2024

Description of changes:

After=network-online.target without Wants=network-online.target doesn't actually do anything (unless by mere luck another service also has a Wants=network-online.target in the same transaction).

This is because network-online.target isn't pulled into the boot transaction by default by systemd to minimize delay of booting if no services require network connectivity. Services that require network connectivity should explicitly pull it in (through a Wants=).

There's an entire FAQ page dedicated to this bug here: https://systemd.io/NETWORK_ONLINE/

Note that normally, if no service requires it and if no remote mount point is configured, this target is not pulled into the boot, thus avoiding any delays during boot should the network not be available.

How do I make sure that my service starts after the network is really online?
That depends on your setup and the services you plan to run after it (see above). If you need to delay you service after network connectivity has been established, include

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

in the .service file.

This will delay boot until the network management software > says the network is “up”. For details, see the next question.

Issue #, if available:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

`After=network-online.target` without `Wants=network-online.target` doesn't actually do anything (unless by mere luck another service also has a `Wants=network-online.target` in the same transaction).

This is because `network-online.target` isn't pulled into the boot transaction by default by systemd to minimize delay of booting if no services require network connectivity.  Services that require network connectivity should explicitly pull it in (through a `Wants=`).

There's an entire FAQ page dedicated to this bug here: https://systemd.io/NETWORK_ONLINE/

> Note that normally, if no service requires it and if no remote mount point is configured, this target is not pulled into the boot, thus avoiding any delays during boot should the network not be available. 


> How do I make sure that my service starts after the network is really online?
> That depends on your setup and the services you plan to run after it (see above). If you need to delay you service after network connectivity has been established, include
> 
> ```
> After=network-online.target
> Wants=network-online.target
> in the .service file.
> ```
> 
> This will delay boot until the network management software > says the network is “up”. For details, see the next question.
@arianvp
Copy link
Author

arianvp commented Jun 10, 2024

Note that if ssm-agent has sufficient retries when the network is not up; it might just be worthwhile to drop the whole waiting for network business completely.

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 this pull request may close these issues.

1 participant