bind: make systemd service wait for BIND to be ready

Without this change, the systemd unit will be marked as ready even though BIND has not finished starting yet.
This causes other units that depend on BIND to start even though BIND is not ready yet.
From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900788: "Bind9 will daemonize itself _when it is ready_."

Also modify the NixOS test. With this change, waiting for the unit alone will ensure that BIND is ready to accept queries. I would have expected to see the test failing without this commit but with the `machine.wait_for_open_port(53)` line removed but I found this to not be the case most of the time. This is probably the case because the situation is inherently racy and on my machine BIND happens to start in time most of the time.
This commit is contained in:
Luflosi 2024-05-31 13:13:41 +02:00
parent 4e2290525d
commit 8e945401d5
No known key found for this signature in database
GPG Key ID: 743C5DD6900A1FF0
2 changed files with 2 additions and 2 deletions

View File

@ -271,7 +271,8 @@ in
''; '';
serviceConfig = { serviceConfig = {
ExecStart = "${bindPkg.out}/sbin/named -u ${bindUser} ${optionalString cfg.ipv4Only "-4"} -c ${cfg.configFile} -f"; Type = "forking"; # Set type to forking, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900788
ExecStart = "${bindPkg.out}/sbin/named -u ${bindUser} ${optionalString cfg.ipv4Only "-4"} -c ${cfg.configFile}";
ExecReload = "${bindPkg.out}/sbin/rndc -k '/etc/bind/rndc.key' reload"; ExecReload = "${bindPkg.out}/sbin/rndc -k '/etc/bind/rndc.key' reload";
ExecStop = "${bindPkg.out}/sbin/rndc -k '/etc/bind/rndc.key' stop"; ExecStop = "${bindPkg.out}/sbin/rndc -k '/etc/bind/rndc.key' stop";
}; };

View File

@ -22,7 +22,6 @@ import ./make-test-python.nix {
testScript = '' testScript = ''
machine.wait_for_unit("bind.service") machine.wait_for_unit("bind.service")
machine.wait_for_open_port(53)
machine.succeed("host 192.168.0.1 127.0.0.1 | grep -qF ns.example.org") machine.succeed("host 192.168.0.1 127.0.0.1 | grep -qF ns.example.org")
''; '';
} }