Skip to content
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/tinydns: port test to python #73059

Merged
merged 2 commits into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nixos/modules/services/networking/tinydns.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ with lib;
systemd.services.tinydns = {
description = "djbdns tinydns server";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should never use network.target: it's meant to be pulled in by services providing the network link/setup, like dhcpcd. Use network-online.target instead. See #50930 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does tinydns fail horribly during startup if there's no default route? Otherwise, systemd docs explicitly mention we should go after network.target, not network-online.target:

Units that strictly require a configured network connection should pull in network-online.target (via a Wants= type dependency) and order themselves after it. This target unit is intended to pull in a service that delays further execution until the network is sufficiently set up. What precisely this requires is left to the implementation of the network managing service.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does tinydns fail horribly during startup if there's no default route?

Probably not but it's logically not part of setting up the network link and needs an internet connection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't set wants, or make it partOf network.target - we only set an after.

Setting After=network-online.target would mean we wait with starting tinydns until there's a default route. This means if you're enabling tinydns on your laptop, you don't reach multi-user.target until you get an internet connection.

I don't think that's necessary, but tinydns needs to wait until there's a network interface available in the system, so setting After=network.target should be right. 😕

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you are right: I was confusing After with Wants, sorry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries!

path = with pkgs; [ daemontools djbdns ];
preStart = ''
rm -rf /var/lib/tinydns
Expand Down
8 changes: 4 additions & 4 deletions nixos/tests/tinydns.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ./make-test.nix ({ lib, ...} : {
import ./make-test-python.nix ({ lib, ...} : {
name = "tinydns";
meta = {
maintainers = with lib.maintainers; [ basvandijk ];
Expand All @@ -19,8 +19,8 @@ import ./make-test.nix ({ lib, ...} : {
};
};
testScript = ''
$nameserver->start;
$nameserver->waitForUnit("tinydns.service");
$nameserver->succeed("host bla.foo.bar | grep '1\.2\.3\.4'");
nameserver.start()
nameserver.wait_for_unit("tinydns.service")
nameserver.succeed("host bla.foo.bar | grep '1\.2\.3\.4'")
'';
})