From 6a040614c4ffcbda9dc9624d79d83ed2e55577d3 Mon Sep 17 00:00:00 2001 From: davidak Date: Wed, 31 Jul 2019 16:19:18 +0200 Subject: [PATCH] nixos-containers: add TimeoutStartSec option Default is now 1m instead of global default of 15sec. It is also configurable. Fixes issue where start of many containers (40+) fail https://github.com/NixOS/nixpkgs/issues/65001 (cherry picked from commit eba686ddfad91d8f59d61e3ca0e26f1360ff9a81) Reason: Problem exists in stable too --- nixos/modules/virtualisation/containers.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix index d10c4feecb436..88a3ccc655b76 100644 --- a/nixos/modules/virtualisation/containers.nix +++ b/nixos/modules/virtualisation/containers.nix @@ -253,6 +253,10 @@ let RestartForceExitStatus = "133"; SuccessExitStatus = "133"; + # Some containers take long to start + # especially when you automatically start many at once + TimeoutStartSec = cfg.timeoutStartSec; + Restart = "on-failure"; Slice = "machine.slice"; @@ -419,6 +423,7 @@ let { extraVeths = {}; additionalCapabilities = []; + timeoutStartSec = "15s"; allowedDevices = []; hostAddress = null; hostAddress6 = null; @@ -567,6 +572,18 @@ in ''; }; + timeoutStartSec = mkOption { + type = types.str; + default = "1min"; + description = '' + Time for the container to start. In case of a timeout, + the container processes get killed. + See systemd.time + 7 + for more information about the format. + ''; + }; + bindMounts = mkOption { type = with types; loaOf (submodule bindMountOpts); default = {};