-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
nixos: mutually exclusive services; application to acme #102387
Conversation
Doesn't this seem like a shortcoming of upstream |
This seems to me to overlap somewhat with the I think having the services in question acquire (and wait for) a write lock on a common file would be a more elegant approach. |
|
It is different from Conflict in a way similar to how Wants is different from After.
You cannot start conflicting services at the same time, whereas you can start services in the same mutex, they will just be queued and actually started one at a time. This is what the nixos test tests.
It does not help if it is really true that lego corrupts its state when two renewal are started at the same time. Especially because nixos-rebuild tends to start them all at the same time.
This is a valid point. Personally I'm not interested in doing this work, but if it is estimated that this is the better way to go, I'll close this. |
@symphorien understandable if you're not interested in hacking on low level |
I opened an issue upstream. Let's see what they think. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
I marked this as stale due to inactivity. → More info |
Link for completeness: systemd/systemd#17546 |
This actually only works for Type=oneshot services. |
Motivation for this change
In #101445 one of the hypothetical solutions is to ensure certs are renewed one at a time. But this is not the first time I wanted to be able to specify that some oneshot systemd services must not run simultaneously. Notably, I have some periodic io intensive jobs with a timer. To prevent them from running at the same time, I have to choose a unique hour for each of them myself. Instead I would like to set them all to "daily" and mark them as mutually exclusive.
So I implemented a generic solution.
This introduces a
systemd.mutex
options to define sets of mutually exclusive services, working by adding After= and Before= stanzas. The nix implementation is not very pretty and limited to services (does it really make sense on non-services?).As illustrations, I added a test and applied it to acme to see if it fixes #101445. Unfortunately, as it seems we cannot reproduce the issue reliably, it's hard to say if it really fixes it...
I can split the acme commit from the generic implementation if you want, and if the nix code is to ugly I can try other things, but before I'd like to hear some opinions about whether we want this mechanism at all.
Tested with the systemd.nix and acme.nix tests.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)