diff --git a/nix/container-modules/swarm-container.nix b/nix/container-modules/swarm-container.nix index a8b83d7b5..f00e1bf49 100644 --- a/nix/container-modules/swarm-container.nix +++ b/nix/container-modules/swarm-container.nix @@ -114,8 +114,10 @@ in 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 + # `degraded` (a unit of the boot failed) exits 1 and is still over; + # the state goes to the journal next to the start. + state=$(systemctl is-system-running --wait || true) + echo "swarm-container-deferred-start: the boot ended $state; starting ${lib.concatStringsSep " " cfg.startAfterReady}" systemctl start --no-block ${lib.concatMapStringsSep " " (n: "${n}.service") cfg.startAfterReady} ''; }; diff --git a/nix/module-eval/swarm-services-switch.nix b/nix/module-eval/swarm-services-switch.nix index 814b06fa7..fac2cbca3 100644 --- a/nix/module-eval/swarm-services-switch.nix +++ b/nix/module-eval/swarm-services-switch.nix @@ -1013,7 +1013,7 @@ let && starter.wantedBy == [ "multi-user.target" ] && starter.serviceConfig.Type == "simple" && !(bootWait.holdsJob starter) - && lib.hasInfix "systemctl is-system-running --wait >/dev/null || true\nsystemctl start --no-block tuwunel.service" starter.script + && lib.hasInfix "state=$(systemctl is-system-running --wait || true)\necho \"swarm-container-deferred-start: the boot ended $state; starting tuwunel\"\nsystemctl start --no-block tuwunel.service" starter.script && !(lib.elem "tuwunel.service" booted) && lib.elem "swarm-container-deferred-start.service" booted && lib.elem "swarm-matrix-appservice-sync.service" booted diff --git a/nix/vm-tests/container-deferred-start.nix b/nix/vm-tests/container-deferred-start.nix index b833a0adf..bfbab7e43 100644 --- a/nix/vm-tests/container-deferred-start.nix +++ b/nix/vm-tests/container-deferred-start.nix @@ -110,6 +110,10 @@ pkgs.testers.runNixOSTest { "test \"$(nixos-container run new -- systemctl show -p ActiveState --value slow.service)\" = activating", timeout=60, ) + # The starter says which state the boot ended in, next to the start. + out = inside("new", "journalctl -u swarm-container-deferred-start.service --no-pager -o cat") + assert "swarm-container-deferred-start: the boot ended " in out, out + assert "starting slow" in out, out with subtest("the dependant fails while the daemon starts"): assert inside("new", "systemctl show -p ActiveState --value client.service") != "active"