nixos/switch-to-configuration: Ignore path units
This commit is contained in:
parent
de128feacc
commit
adc033cd59
2 changed files with 37 additions and 3 deletions
|
@ -152,7 +152,7 @@ sub fingerprintUnit {
|
|||
sub handleModifiedUnit {
|
||||
my ($unit, $baseName, $newUnitFile, $activePrev, $unitsToStop, $unitsToStart, $unitsToReload, $unitsToRestart, $unitsToSkip) = @_;
|
||||
|
||||
if ($unit eq "sysinit.target" || $unit eq "basic.target" || $unit eq "multi-user.target" || $unit eq "graphical.target" || $unit =~ /\.slice$/) {
|
||||
if ($unit eq "sysinit.target" || $unit eq "basic.target" || $unit eq "multi-user.target" || $unit eq "graphical.target" || $unit =~ /\.slice$/ || $unit =~ /\.path$/) {
|
||||
# Do nothing. These cannot be restarted directly.
|
||||
# Slices and Paths don't have to be restarted since
|
||||
# properties (resource limits and inotify watches)
|
||||
|
@ -161,8 +161,6 @@ sub handleModifiedUnit {
|
|||
# Reload the changed mount unit to force a remount.
|
||||
$unitsToReload->{$unit} = 1;
|
||||
recordUnit($reloadListFile, $unit);
|
||||
} elsif ($unit =~ /\.path$/) {
|
||||
# FIXME: do something?
|
||||
} else {
|
||||
my $unitInfo = parseUnit($newUnitFile);
|
||||
if (boolIsTrue($unitInfo->{'X-ReloadIfChanged'} // "no")) {
|
||||
|
|
|
@ -131,6 +131,26 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
|||
};
|
||||
};
|
||||
|
||||
# A system with a path unit
|
||||
with-path.configuration = {
|
||||
systemd.paths.test-watch = {
|
||||
wantedBy = [ "paths.target" ];
|
||||
pathConfig.PathExists = "/testpath";
|
||||
};
|
||||
systemd.services.test-watch = {
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.coreutils}/bin/touch /testpath-modified";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# The same system but watching another file
|
||||
with-path-modified.configuration = {
|
||||
imports = [ config.specialisation.with-path.configuration ];
|
||||
systemd.paths.test-watch.pathConfig.PathExists = lib.mkForce "/testpath2";
|
||||
};
|
||||
|
||||
# A system with a slice
|
||||
with-slice.configuration = {
|
||||
systemd.slices.testslice.sliceConfig.MemoryMax = "1"; # don't allow memory allocation
|
||||
|
@ -284,6 +304,22 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
|||
assert_contains(out, "would restart the following units: simple-restart-service.service\n")
|
||||
assert_contains(out, "\nwould start the following units: simple-service.service")
|
||||
|
||||
with subtest("paths"):
|
||||
switch_to_specialisation("with-path")
|
||||
machine.fail("test -f /testpath-modified")
|
||||
|
||||
# touch the file, unit should be triggered
|
||||
machine.succeed("touch /testpath")
|
||||
machine.wait_until_succeeds("test -f /testpath-modified")
|
||||
|
||||
machine.succeed("rm /testpath /testpath-modified")
|
||||
switch_to_specialisation("with-path-modified")
|
||||
|
||||
machine.succeed("touch /testpath")
|
||||
machine.fail("test -f /testpath-modified")
|
||||
machine.succeed("touch /testpath2")
|
||||
machine.wait_until_succeeds("test -f /testpath-modified")
|
||||
|
||||
# This test ensures that changes to slice configuration get applied.
|
||||
# We test this by having a slice that allows no memory allocation at
|
||||
# all and starting a service within it. If the service crashes, the slice
|
||||
|
|
Loading…
Reference in a new issue