Watch
0
0
Fork
You've already forked hyperhive
0

fix(matrix): queue tuwunel's start after the guest's boot is over

The deferred starter was a oneshot that ran `systemctl start --no-block
tuwunel` inside the boot transaction. A --no-block start still queues a
start job, so the guest's job queue stayed non-empty for as long as
tuwunel's start took, and the container (Type=notify, --notify-ready=yes,
one minute) never reported ready and was killed at its limit.

The starter is now Type=simple, so its own start job ends at the fork. It
waits for `systemctl is-system-running --wait` and only then queues the
service. The VM test waits for the daemon to reach `activating` instead of
asserting it the moment the container's start ends.
This commit is contained in:
maia 2026-11-28 05:57:08 +01:00 • committed by mara
commit 3919de6358

View file

@ -21,8 +21,8 @@
#
# A daemon whose own start can outlast that limit (a database open that replays
# a large log) is named in `startAfterReady`: it leaves the boot transaction, so
# the container is up without it, and a oneshot in the transaction starts it
# `--no-block`.
# the container is up without it, and a unit that waits for the boot to end
# starts it `--no-block`.
{
config,
lib,
@ -53,7 +53,8 @@ in
Names of this container's services (without `.service`) that start
after the container's boot instead of in it. Each stops being wanted
by `multi-user.target`, and `swarm-container-deferred-start.service`,
which is, starts them with `systemctl start --no-block`. The host's
which is, starts them with `systemctl start --no-block` once the
guest's boot is over. The host's
start job for the container then ends when the guest's boot does,
whatever the service's own start takes. The service keeps its own
`TimeoutStartSec`, and whatever depends on it has to cope with a
@ -100,18 +101,23 @@ in
wantedBy = lib.mkForce [ ];
})
// {
# Its own job ends at the enqueue, so the boot does not wait on the
# services it starts.
# A `--no-block` start still queues the service's start job, and the
# container's start ends when the guest's job queue is empty
# (nixos-containers.nix passes `--notify-ready=yes`, and the host
# unit is `Type=notify`). So the job is queued after the boot, not
# in it: this unit is `Type=simple`, whose own start job ends at the
# fork, and it waits for the manager to leave `starting` before it
# queues the services.
swarm-container-deferred-start = {
description = "start the services that outlast the container's start limit";
description = "start the services that outlast the container's start limit, once its boot is over";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
TimeoutStartSec = 20;
ExecStart = "${pkgs.systemd}/bin/systemctl start --no-block ${
lib.concatMapStringsSep " " (n: "${n}.service") cfg.startAfterReady
}";
};
path = [ pkgs.systemd ];
serviceConfig.Type = "simple";
script = ''
# `degraded` (a unit of the boot failed) exits 1 and is still over.
systemctl is-system-running --wait >/dev/null || true
systemctl start --no-block ${lib.concatMapStringsSep " " (n: "${n}.service") cfg.startAfterReady}
'';
};
};
})