Repository navigation
Conversation
|
My experience with these kind of setups is that they are an unmitigated disaster, because they are invariably used by services that cannot do process management right and get it awfully wrong, and manage to completely break the node. Can't the exact same result be obtained by simply using the FD store to pass FDs over? There should be no interruptions or connection closures in that case. |
Not closing file descriptors (i.e. not dropping connections) is just part of the issue. More complex problem is usually state transfer from one invocation of the service to another. Not that many traditional services implement it because it is inherently difficult to do in C. |
|
Yeah for my use case I'm having everyone who needs that switch to store state in memfds that can be passed over. I'd recommend you do the same if you have a specific use case scenario where this is coming from, as you are going to find yourself in a world of hurt when broken services start using this... A neverending cascade of processes using cpu/memory/disk resources and never terminating and so on. Not a pretty sight. Been there, done that ;-) |
|
Would this change address the issue that local users can impersonate services by crashing them if they do not listen on privileged ports? Previous discussion: |
5a87b1a to
078e21a
Compare
078e21a to
e51c298
Compare
Main motivation for this work is to allow zero-downtime service restarts. Currently the restart of a service unit is composed of two main steps, stop of the currently running service which is then followed by start of the service. This prevents the service from running long-term after restart of the service is initiated. Therefore, clients of the service can experience the disruption as their connection to the service can be abruptly terminated. This can be partly mitigated by setting using non-default KillMode= and adjusting TimeoutStopSec= timeout. However, full mitigation of this behavior is currently not possible. This commit introduces a new systemd features that will allow an old version of a service (generation) to continue running until it voluntarily exits or the service is explicitly stopped. Main goal is to allow for undisturbed handling of previously started work (e.g. client connections, system management operations) to run into full completion even if the service is restarted. It is expected that clients requesting the service after the restart will communicate with the latest version (generation) of the service. This behavior will be achieved using a combination of two newly introduced service unit options, RestartMode= and ExecRestart=. Fixes: systemd#10228 TODO ---- - [bug] main service cgroup stays around after stop of the service - [design] figure out behavior in combination with KillMode=process|mixed - [design] is UNIT_MAINTAINANCE state appropriate for RestartMode=keep ? - [bug] RestarMode property exported over dbus - [bug] ExecRestart= is not exported over dbus - [bug] Support for transient units - [tests] - add test cases for different KillModes= - maybe rewrite the test using Beakerlib?
e51c298 to
fe14590
Compare
I don't think that this feature would help with this problem. |
|
I like:
I don't like:
I have yet to understand the lifecycle changes better. Soon (tm), I should be able to put forward an alternate approach, I've been cooking recently to pick the best of both ;-) |
|
As discussed on that videocall that one time, we think it's nicer not to support something like this explicitly, but instead push people towards:
This should generally be a safer simpler outcome because we can maintain our guarantee that everything we start anew for the service comes with a clean set of process/security settings, cgroup parameters and so on. We also discussed maybe simplifiyng step 3 by providing an asynchronous sd_notify() based API for moving processes to keep around to an auxiliary scope unit. |
|
Maybe it's worth trying to upgrade different types of program to use such a scheme, and then comparing? Off hand I don't see how it's possible to cheaply do that for even something quite simple like a static file server, as the state would need to be serialized for things like the entire TLS stack, the open fds of the file being served, etc. It could be done as an interesting academic exercise but it seems clear that the cost would be a lot higher than just letting new inbound connections be handled by the new instance and let the old instance finish when done. And once you get into app servers that can have arbitrarily complex connection state, it seems to become totally unrealistic given that other systems will happily let a transition between old and new instances happen with them both overlapping. |
|
I'm not sure I buy that it's not possible to pass state around by FD, sure it requires some work, but so what, everything does. The alternative is just hopelessly broken by design. |
|
Don't most service providers achieve this kind of thing at the network/"cloud" granularity these days? i.e. You direct users to the updated instances at the load balancer, and it's on you to provide resources for those lingering sessions pinning the old world if it's so important to provide Zero Down Time. Because at the end of the day, that's what's required to do it right in a generally correct fashion without shitting the bed in unpredictable ways - pinning resources to the old world until the refcount drops to zero. While ensuring the new world isn't stepping on the old's global state in the databases/filesystems/whatever snowflake external app-specific dependencies people are paid big bucks to understand and worry about. Do we really want systemd to get in that inherently messy business at the service level within a single host? It seems misguided to me. At best I'd think systemd could maybe offer some features in the spirit of narrowing the service down time window as much as possible, more like Epsilon Down time, by permitting some pre-available-for-service startup stuff to overlap before replacement. But still having a clean break where the old is replaced with the new, and connections must be reestablished etc. |
|
Yeah that's what the FD store and scopes are supposed to help with as mentioned above |
|
Replaced by #28836 |
Main motivation for this work is to allow zero-downtime service restarts. Currently the restart of a service unit is composed of two main steps, stop of the currently running service which is then followed by start of the service. This prevents the service from running long-term after restart of the service is initiated. Therefore, clients of the service can experience the disruption as their connection to the service can be abruptly terminated. This can be partly mitigated by setting using non-default KillMode= and adjusting TimeoutStopSec= timeout. However, full mitigation of this behavior is currently not possible.
This commit introduces a new systemd features that will allow an old version of a service (generation) to continue running until it voluntarily exits or the service is explicitly stopped. Main goal is to allow for undisturbed handling of previously started work (e.g. client connections, system management operations) to run into full completion even if the service is restarted. It is expected that clients requesting the service after the restart will communicate with the latest version (generation) of the service.
This behavior will be achieved using a combination of two newly introduced service unit options, RestartMode= and ExecRestart=.
Fixes: #10228
TODO