Merge pull request #62779 from grahamc/containers-restart

Restart declarative containers when their host environment configuration changes
This commit is contained in:
Graham Christensen 2019-06-06 12:57:23 -04:00 committed by GitHub
commit 9d11c30cf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -689,7 +689,7 @@ in
[{ name = "container@"; value = unit; }]
# declarative containers
++ (mapAttrsToList (name: cfg: nameValuePair "container@${name}" (let
config = cfg // (
containerConfig = cfg // (
if cfg.enableTun then
{
allowedDevices = cfg.allowedDevices
@ -700,18 +700,21 @@ in
else {});
in
unit // {
preStart = preStartScript config;
script = startScript config;
postStart = postStartScript config;
serviceConfig = serviceDirectives config;
preStart = preStartScript containerConfig;
script = startScript containerConfig;
postStart = postStartScript containerConfig;
serviceConfig = serviceDirectives containerConfig;
} // (
if config.autoStart then
if containerConfig.autoStart then
{
wantedBy = [ "machines.target" ];
wants = [ "network.target" ];
after = [ "network.target" ];
restartTriggers = [ config.path ];
reloadIfChanged = true;
restartTriggers = [
containerConfig.path
config.environment.etc."containers/${name}.conf".source
];
restartIfChanged = true;
}
else {})
)) config.containers)