mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
core: don't consider SERVICE_SKIP_CONDITION for abnormal or failure restarts
Fixes: #16115
This commit is contained in:
parent
6a881daf85
commit
bb9244781c
|
@ -1703,10 +1703,10 @@ static bool service_shall_restart(Service *s, const char **reason) {
|
||||||
return s->result == SERVICE_SUCCESS;
|
return s->result == SERVICE_SUCCESS;
|
||||||
|
|
||||||
case SERVICE_RESTART_ON_FAILURE:
|
case SERVICE_RESTART_ON_FAILURE:
|
||||||
return s->result != SERVICE_SUCCESS;
|
return !IN_SET(s->result, SERVICE_SUCCESS, SERVICE_SKIP_CONDITION);
|
||||||
|
|
||||||
case SERVICE_RESTART_ON_ABNORMAL:
|
case SERVICE_RESTART_ON_ABNORMAL:
|
||||||
return !IN_SET(s->result, SERVICE_SUCCESS, SERVICE_FAILURE_EXIT_CODE);
|
return !IN_SET(s->result, SERVICE_SUCCESS, SERVICE_FAILURE_EXIT_CODE, SERVICE_SKIP_CONDITION);
|
||||||
|
|
||||||
case SERVICE_RESTART_ON_WATCHDOG:
|
case SERVICE_RESTART_ON_WATCHDOG:
|
||||||
return s->result == SERVICE_FAILURE_WATCHDOG;
|
return s->result == SERVICE_FAILURE_WATCHDOG;
|
||||||
|
|
1
test/TEST-51-ISSUE-16115/Makefile
Symbolic link
1
test/TEST-51-ISSUE-16115/Makefile
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../TEST-01-BASIC/Makefile
|
6
test/TEST-51-ISSUE-16115/test.sh
Executable file
6
test/TEST-51-ISSUE-16115/test.sh
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
TEST_DESCRIPTION="Test ExecCondition= does not restart on abnormal or failure"
|
||||||
|
. $TEST_BASE_DIR/test-functions
|
||||||
|
|
||||||
|
do_test "$@" 51
|
9
test/units/testsuite-51-repro-1.service
Normal file
9
test/units/testsuite-51-repro-1.service
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Issue 16115 Repro with on-abnormal
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=on-abnormal
|
||||||
|
ExecCondition=/bin/false
|
||||||
|
ExecStart=sleep 100
|
||||||
|
RestartSec=1
|
9
test/units/testsuite-51-repro-2.service
Normal file
9
test/units/testsuite-51-repro-2.service
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Issue 16115 Repro with on-failure
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=on-failure
|
||||||
|
ExecCondition=/bin/false
|
||||||
|
ExecStart=sleep 100
|
||||||
|
RestartSec=1
|
7
test/units/testsuite-51.service
Normal file
7
test/units/testsuite-51.service
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[Unit]
|
||||||
|
Description=TEST-51-ISSUE-16115
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStartPre=rm -f /failed /testok
|
||||||
|
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
|
||||||
|
Type=oneshot
|
12
test/units/testsuite-51.sh
Executable file
12
test/units/testsuite-51.sh
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
systemctl start testsuite-51-repro-1
|
||||||
|
systemctl start testsuite-51-repro-2
|
||||||
|
sleep 5 # wait a bit in case there are restarts so we can count them below
|
||||||
|
|
||||||
|
[[ "$(systemctl show testsuite-51-repro-1 -P NRestarts)" == "0" ]]
|
||||||
|
[[ "$(systemctl show testsuite-51-repro-2 -P NRestarts)" == "0" ]]
|
||||||
|
|
||||||
|
touch /testok
|
Loading…
Reference in a new issue