gdraheim / docker-systemctl-replacement

docker systemctl replacement - allows to deploy to systemd-controlled containers without starting an actual systemd daemon (e.g. centos7, ubuntu16)
European Union Public License 1.2
1.39k stars 399 forks source link

StartLimitIntervalSec=0 or how to Restart Forever #170

Open tunafishman opened 12 months ago

tunafishman commented 12 months ago

I'm currently using a service from a vendor who seems to have ported their setup into k8s by using this python replacement for systemd as the entrypoint to the containers. Their product relies on a service running via systemctl which keeps a connection to a server pod. When that server pod gets restarted the service loses connection and fails.

The service is configured with StartLimitIntervalSec=0 in the [Unit] definition which, according to resources like this one will mean that it gets restarted forever and will eventually, in this case, find a reference to the new server pod. Unfortunately that seems to not work in this python driven universe. The service fails and the product falls down and needs manual intervention via kubectl exec to run systemctl restart and get things back on track. In my case that means anything like automatic patching is guaranteed to break the whole system unless the entire process is babysat.

I did experiment and see that StartLimitIntervalSec=0 in the [Unit] section doesn't seem to override the systemctl.py default of 10, but placing it within the [Service] definition does. And even then the underlying restart loop doesn't seem to give the expected behavior when this value is set to 0.

Tl;Dr: Is there a way to configure a service via systemctl3.py such that it will continue trying to Restart forever?

gdraheim commented 9 months ago

According to the documentation, there is a special value "infinity" - the usage of =0 is not documented.

https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#StartLimitIntervalSec=interval