summaryrefslogtreecommitdiffstats
path: root/test/test-path
diff options
context:
space:
mode:
authorMichael Chapman <mike@very.puzzling.org>2020-05-05 05:50:04 +0200
committerMichael Chapman <mike@very.puzzling.org>2020-05-05 05:56:02 +0200
commit708961c7011b7578d3e6e10ca463d15edb62b5c1 (patch)
tree04718bb896d254af53be3755eac1d5daf49d1b8e /test/test-path
parentcore/path: use escaped path in serialization (diff)
downloadsystemd-708961c7011b7578d3e6e10ca463d15edb62b5c1.tar.xz
systemd-708961c7011b7578d3e6e10ca463d15edb62b5c1.zip
core/path: recheck path specs when triggered unit changes state
As documented in systemd.path(5): When a service unit triggered by a path unit terminates (regardless whether it exited successfully or failed), monitored paths are checked immediately again, and the service accordingly restarted instantly. This commit implements this behaviour for PathExists=, PathExistsGlob=, and DirectoryNotEmpty=. These predicates are essentially "level-triggered": the service should be activated whenever the predicate is true. PathChanged= and PathModified=, on the other hand, are "edge-triggered": the service should only be activated when the predicate *becomes* true. The behaviour has been broken since at least as far back as commit 8fca6944c2 ("path: stop watching path specs once we triggered the target unit"). This commit had systemd stop monitoring inotify whenever the triggered unit was activated. Unfortunately this meant it never updated the ->inotify_triggered flag, so it never rechecked the path specs when the triggered unit deactivated. With this commit, systemd rechecks all paths specs whenever the triggered unit deactivates. If any PathExists=, PathExistsGlob= or DirectoryNotEmpty= predicate passes, the triggered unit is reactivated. If the target unit is activated by something outside of the path unit, the path unit immediately transitions to a running state. This ensures the path unit stops monitoring inotify in this situation. With this change in place, commit d7cf8c24d4 ("core/path: fix spurious triggering of PathExists= on restart/reload") is no longer necessary. The path unit (and its triggered unit) is now always active whenever the PathExists= predicate passes, so there is no spurious restart when systemd is reloaded or restarted.
Diffstat (limited to 'test/test-path')
-rw-r--r--test/test-path/path-changed.service3
-rw-r--r--test/test-path/path-directorynotempty.service3
-rw-r--r--test/test-path/path-exists.service3
-rw-r--r--test/test-path/path-existsglob.service3
-rw-r--r--test/test-path/path-makedirectory.service3
-rw-r--r--test/test-path/path-modified.service3
-rw-r--r--test/test-path/path-mycustomunit.service5
7 files changed, 15 insertions, 8 deletions
diff --git a/test/test-path/path-changed.service b/test/test-path/path-changed.service
index f8499ec619..fb465d76bb 100644
--- a/test/test-path/path-changed.service
+++ b/test/test-path/path-changed.service
@@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
-Type=oneshot
+Type=simple
+RemainAfterExit=true
diff --git a/test/test-path/path-directorynotempty.service b/test/test-path/path-directorynotempty.service
index f8499ec619..fb465d76bb 100644
--- a/test/test-path/path-directorynotempty.service
+++ b/test/test-path/path-directorynotempty.service
@@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
-Type=oneshot
+Type=simple
+RemainAfterExit=true
diff --git a/test/test-path/path-exists.service b/test/test-path/path-exists.service
index f8499ec619..fb465d76bb 100644
--- a/test/test-path/path-exists.service
+++ b/test/test-path/path-exists.service
@@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
-Type=oneshot
+Type=simple
+RemainAfterExit=true
diff --git a/test/test-path/path-existsglob.service b/test/test-path/path-existsglob.service
index f8499ec619..fb465d76bb 100644
--- a/test/test-path/path-existsglob.service
+++ b/test/test-path/path-existsglob.service
@@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
-Type=oneshot
+Type=simple
+RemainAfterExit=true
diff --git a/test/test-path/path-makedirectory.service b/test/test-path/path-makedirectory.service
index f8499ec619..fb465d76bb 100644
--- a/test/test-path/path-makedirectory.service
+++ b/test/test-path/path-makedirectory.service
@@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
-Type=oneshot
+Type=simple
+RemainAfterExit=true
diff --git a/test/test-path/path-modified.service b/test/test-path/path-modified.service
index f8499ec619..fb465d76bb 100644
--- a/test/test-path/path-modified.service
+++ b/test/test-path/path-modified.service
@@ -3,4 +3,5 @@ Description=Service Test for Path units
[Service]
ExecStart=/bin/true
-Type=oneshot
+Type=simple
+RemainAfterExit=true
diff --git a/test/test-path/path-mycustomunit.service b/test/test-path/path-mycustomunit.service
index 172ac0d0d5..bcdafe4f30 100644
--- a/test/test-path/path-mycustomunit.service
+++ b/test/test-path/path-mycustomunit.service
@@ -1,6 +1,7 @@
[Unit]
-Description=Service Test Path Unit=
+Description=Service Test Path Unit
[Service]
ExecStart=/bin/true
-Type=oneshot
+Type=simple
+RemainAfterExit=true