-
-
Notifications
You must be signed in to change notification settings - Fork 14k
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
resolvconf service: init #62955
resolvconf service: init #62955
Conversation
(Messed up with issue numbers, I meant #61490). |
b9a9a31
to
740fe57
Compare
What's the status of this PR? |
I have several machines with it but given it's a non-trivial networking refactor I'd like someone to review this before merging.
…On June 21, 2019 8:54:11 AM GMT+03:00, Ivan Malison ***@***.***> wrote:
What's the status of this PR.
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#62955 (comment)
--
Nikolay.
|
9be5ae0
to
c1153c8
Compare
I want to get rid of as many activation scripts as possible and the current resolvconf snippet was making my head hurt, so I went looking and found this PR. I think your approach brings more clarity to these modules. I like it! I do have some questions though. It doesn't appear to me that removing I'm skeptical about the commands in As far as I can tell, But is there any way we could avoid invoking resolvconf during activation? I think it might work to create a oneshot service with The new assertion in Okay, that's all I have brain for at the moment. I hope this was helpful and I'll try to keep an eye on this PR. |
So far, I've only read through the changes - I haven't tried it out yet, but it looks good to me! The only case not covered by this would be if one wants NetworkManager to explicitly control I'm seconding @jameysharp's remarks, though: in particular, removing |
@jameysharp @talyz Thank you both for your comments! I've updated the patch. Instead of somehow forbidding resolvconf usage in I also moved resolvconf update to a systemd unit as per @jameysharp suggestion, it seems to work nicely! A possible improvement would be to add support for pre-activation commands into stage-2 and split handling of host-provided |
@talyz, I also thought about the loss of the ability to make NetworkManager control resolv.conf and I agree, it doesn't seem important. @abbradar Ooh, I'm glad the oneshot unit thing worked here. I bet I can apply it other places too... I'm not entirely comfortable with hoping that nothing will call resolvconf just because we haven't told it to. The consequence if we're wrong is that networking breaks, sometimes, unpredictably, which would lead to bug reports that look similar to #61230. From a quick Instead I'd prefer to ensure that if something does go wrong, it fails in a predictable way and without discarding the configured settings. Since echo "resolvconf is disabled on this system but was used anyway:" >&2
echo "$0 $*" >&2
exit 1 Which I hope would help track down things which we didn't expect would be using it. A more extreme approach would be to set I'm not totally convinced that I'm pretty sure the "import host's resolv.conf into resolvconf" step can be a oneshot service ordered before |
@jameysharp The problem of host's resolv.conf is that we need to do this only at the boot time, so systemd service or activation script is problematic. Otherwise we cannot reliably distinguish if current After some thought I agree we should protect against random usage of resolvconf. Thank you for a nice suggestion about using Moving the |
I thought the case of host resolv.conf was funny because usually when I've been trying to replace activation scripts, the problem has been how to get a systemd unit to run not just at boot, but also on switch-to-configuration. So in this case, where we actually want it to only run at boot, I think that's the easy case. 😁 But it isn't important right now. From reading the manual pages, it looks like systemd-resolved has a number of different modes for how it treats resolv.conf, but I don't think any of them have special treatment for a host-provided copy. Either Because it is hard for me to reason about, I still lean toward not renaming that option in this patch. But I'm not going to push, especially since I have no say in whether this PR gets merged. 😁 As far as I can tell, nixos/modules/system/boot/resolved.nix no longer needs to have a Aside from those two quibbles, I think this is a good patch and I'd be in favor of somebody merging it. |
@jameysharp I'm just wary of using file flags for one-time initialization, no other reason. Maybe you have any ideas about how to ensure that this code runs only once? I grepped through systemd-resolved and systemd-nspawn code today and I think you are right - nspawn and resolved don't communicate in any way, and it's up to user to specify desired Therefore it'll indeed be better for this option to be top-level and various modules to deal with it in their various ways. I'll revert this change, thanks! |
This is a refactor of how resolvconf is managed on NixOS. We split it into a separate service which is enabled internally depending on whether we want /etc/resolv.conf to be managed by it. Various services now take advantage of those configuration options. We also now use systemd instead of activation scripts to update resolv.conf. NetworkManager now uses the right option for rc-manager DNS automatically, so the configuration option shouldn't be exposed.
Okay, I endorse commit 01b90dc! I've re-read it carefully after all these changes and I think it should be merged as-is. I can't do that myself though. I'll outline what I'm thinking should work for making a systemd unit replace the Let's consider the constraints. This statement needs to:
It must not run if, for example, the activation script is re-run, even if the relevant configuration changes; and the admin should be protected from accidentally running it. I think a configuration like this should work: {
systemd.services.host-resolvconf = {
# ensure that no matter what else happens, this happens during initial boot
wantedBy = [ "sysinit.target" ];
# ensure network managers don't start until this is done
wants = [ "network-pre.target" ];
before = [ "network-pre.target" ];
unitConfig = {
# protect the admin or switch-to-configuration from accidentally running this again
RefuseManualStart = true;
# make systemd remember that this already ran, so no dependency can pull it in again
RefuseManualStop = true;
RemainAfterExit = true;
# only run if there's something to do
ConditionFileNotEmpty = "/etc/resolv.conf";
StandardInput = "file:/etc/resolv.conf";
ExecStart = "${pkgs.openresolv}/bin/resolvconf -m 1000 -a host";
};
};
} |
@jameysharp I should confess, I didn't consider systemd to be a possible way of handling this! Nice idea! I agree; let's leave that for another time. Given that I tested this on several configurations (servers, clients, containers) and we did quite a several rounds of review (thanks!) I'll merge this in several days unless anyone else wants to take a stab at reviewing and testing. |
...wait, did you have that "Member" tag all along and I just didn't notice, or did you just recently get commit rights? 😕 Anyway, sounds great 😁 |
For quite a long time actually :3 |
Oh... Maybe you could review/merge some of my pending pull requests? 😁 #64387 is a small patch that's necessary to get one of the tests to work again; #64268 has a "LGTM" from the person who's done the most work in the same area recently; and #63541 has several thumbs-ups and an approval review. I'm just not sure how to get them merged. |
@abbradar, I hadn't realized until I tried this in conjunction with my no-networking patches that setting
Should there be a |
@jameysharp Yeah, the idea is to abstract away how exactly it's chosen from other programs. |
Motivation for this change
This is a refactor of how resolvconf is managed on NixOS. We split it
into a separate service which is enabled internally depending on whether
we want /etc/resolv.conf to be managed by it. Various services now take
advantage of those configuration options, in particular NetworkManager
which fixes #61490.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Tested that #61490 is fixed.