core: Propagate condition failed state to triggering units.
Alternative to https://github.com/systemd/systemd/pull/20531. Whenever a service triggered by another unit fails condition checks, stop the triggering unit to prevent systemd busy looping trying to start the triggered unit.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Unit]
|
||||
ConditionPathExists=!/tmp/nonexistent
|
||||
ConditionPathExists=/tmp/nonexistent
|
||||
|
||||
[Service]
|
||||
ExecStart=true
|
||||
|
||||
@@ -13,5 +13,5 @@ ExecStart=-socat -T20 OPEN:test.file UNIX-CONNECT:/run/test.ctl
|
||||
# systemd enough time even on slower machines, to reach the trigger limit.
|
||||
ExecStart=sleep 10
|
||||
ExecStart=sh -x -c 'test "$(systemctl show test10.socket -P ActiveState)" = failed'
|
||||
ExecStart=sh -x -c 'test "$(systemctl show test10.socket -P Result)" = trigger-limit-hit'
|
||||
ExecStart=sh -x -c 'test "$(systemctl show test10.socket -P Result)" = service-condition-failed'
|
||||
ExecStart=sh -x -c 'echo OK >/testok'
|
||||
|
||||
@@ -8,10 +8,10 @@ Type=oneshot
|
||||
ExecStart=rm -f /tmp/nonexistent
|
||||
ExecStart=systemctl start test63.path
|
||||
ExecStart=touch /tmp/test63
|
||||
# Make sure systemd has sufficient time to hit the start limit for test63.service.
|
||||
ExecStart=sleep 2
|
||||
ExecStart=sh -x -c 'test "$(systemctl show test63.service -P ActiveState)" = failed'
|
||||
ExecStart=sh -x -c 'test "$(systemctl show test63.service -P Result)" = start-limit-hit'
|
||||
# Ensure both the service and the corresponding path unit go inactive due to the failed condition check.
|
||||
ExecStart=sh -x -c 'test "$(systemctl show test63.service -P ActiveState)" = inactive'
|
||||
ExecStart=sh -x -c 'test "$(systemctl show test63.service -P Result)" = success'
|
||||
ExecStart=sh -x -c 'test "$(systemctl show test63.path -P ActiveState)" = failed'
|
||||
ExecStart=sh -x -c 'test "$(systemctl show test63.path -P Result)" = unit-start-limit-hit'
|
||||
ExecStart=sh -x -c 'test "$(systemctl show test63.path -P Result)" = unit-condition-failed'
|
||||
ExecStart=sh -x -c 'echo OK >/testok'
|
||||
|
||||
Reference in New Issue
Block a user