start up dependency in gentoo systemd service

25 Views Asked by At

I work with a system of 20+ Virtual Machines with gentoo linux (systemd) with dynamic dhcp from one of them.

A problem rose that some services running on the VMs require the host VM to have a name for proper service start-up, because if its the default one (gentoo), the service takes it and does not update it later, thus not working properly in conjunction with other VMs' services. VMs start all at once and server is not that fast, the whole start up sequence takes up to 10 minutes, so some VMs might be up waiting for their names for a long while.

One of the systemd features is "systemd-networkd-wait-online.service"

I found a solution to set a custom service dependency for such services as: /etc/systemd/system/.service.d/customdependency.conf

[Unit]
Requires=systemd-networkd-wait-online.service
After=systemd-networkd-wait-online.service

and override this dependency futher as: /etc/systemd/system/systemd-networkd-wait-online.service.d/override.conf

[Service]
TimeoutStopSec=
TimeoutStopSec=infinity (or 7200 for 2hours)

Still for some reason the systemd-networkd-wait-online times out with "Timeout occurred while waiting for network connectivity." after 2 minutes after starting. Which is a problem since i could not even find a place where this 2 minutes are coming from. (it behaves this way on different VMs and always 2min +/- 1-2 seconds) However if it does start and successfully finish the consecutive services start as they should using proper VM name.

UPDATE:

As it turns out after double checking the man page for the service itself, it has an internal timeout "timer" set to 120 seconds, which is exactly what i see in logs. Since the systems in question use default parameters for this particular service, it's ExecStart can be safely overloaded as follows:

/etc/systemd/system/systemd-networkd-wait-online.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --timeout=0

which in return made the service wait unlimited time and postpone any dependant services from launch

0

There are 0 best solutions below