-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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-specific systemd patch makes tmpfiles.d unreliable #47550
Comments
Here is the send-keys feature for reference: https://github.com/NixOS/nixops/blob/master/nix/keys.nix#L249 |
@Mic92 Thanks for the pointer. I also needed to see the other half of the implementation (e.g. https://github.com/NixOS/nixops/blob/v1.6.1/nixops/backends/__init__.py#L209). It seems to me that the best fix for that is to override
That drops I'd apply this override in @volth True, but |
This could be resolved with the work on #61321. The workarounds added for The nixops configuration I used to verify this on 19.03 and my systemd v242 PR is the following: {
server = {
deployment.targetEnv = "libvirtd";
fileSystems."/secret" = {
device = "/dev/mapper/secretdisk";
options = [ "_netdev" ];
};
deployment.autoLuks = {
secretdisk = {
device = "/dev/vda";
passphrase = "foobar";
autoFormat = true;
};
};
};
} (I had to manually add the volume via virt-manager) See also #56265 (comment) for a related discussion (cc @flokli). |
The If you specify that mount option, is the systemd upgrade even necessary? Even systemd 239 from NixOS 19.03 documents that mount option in |
The system upgrade is not required but I am working on this as part of the upgrade (and an ongoing effort to remove more custom patches from systemd). So the behavior will likely only change with 19.09 (or the unstable equivalent). Right now I am trying to figure out how to make the migration without breaking everyone's NixOps deployments. We had a bit of a discussion on #nixos-dev last night and adding an additional (required) option to the The issue with automagically adding the mount option to all the fstab entries is that we can not tell which of them depends on an With a new mandatory |
@jameysharp systemd 242 was merged to master, with patches mentioned in the OP reverted. |
Hooray, thank you!
|
Many NixOS modules now rely on
systemd.tmpfiles.rules
to set up files and directories needed for their service units to start. There used to be documentation advising against doing so, but that documentation was removed in 2017 in 43404d9, and in a quick search I found quite a few recent merged pull requests adding more uses of tmpfiles.d.However, a 2014 patch against systemd by @edolstra (NixOS/systemd@91702db) makes tmpfiles.d unreliable for this purpose.
Normal systemd service units automatically depend on
sysinit.target
being reachedBefore
the service. Upstream'ssystemd-tmpfiles-setup.service
also explicitly declares that it must finishBefore
thesysinit.target
unit. So normally services can rely on their tmpfiles having been created before the service starts.In the NixOS fork of systemd,
systemd-tmpfiles-setup.service
no longer has aBefore
dependency declared onsysinit.target
, which means that regular services can start beforesystemd-tmpfiles
has finished. So there's a race condition that may sometimes prevent a service from starting.In practice,
systemd-tmpfiles
is pretty fast, and even if a service fails to start systemd will probably retry it, so observing this bug in the wild is probably pretty unlikely. Still, I'd be a lot happier if this race condition were closed entirely.The original commit message said that this patch was to avoid an indirect dependency from
sshd.service
onlocal-fs.target
, because that interferes somehow with the NixOpssend-keys
feature. But it didn't explain why that was a problem, so I can't tell whether it's still an issue today. If it's still important, there are probably better ways to fix it, like perhaps settingDefaultDependencies=no
onsshd.service
and explicitly listing its true dependencies, but I can't be sure without an explanation of the underlying NixOps issue.I'd encourage reverting NixOS/systemd@91702db and its rebased equivalents in any branches that are still used by supported versions of NixOS. I'm happy to help brainstorm alternative fixes that don't have such widespread side effects, given some pointers on what problem this patch was actually trying to solve.
The text was updated successfully, but these errors were encountered: