mirror of
https://github.com/systemd/systemd.git
synced 2025-05-27 21:05:55 +03:00
core: do not restart a service with Restart=always when ExecCondition fails
When a Condition*= fails, and a service has Restart=always, the service is not restarted. Follow the same behaviour for ExecCondition= to avoid inconsistencies. Fixes #22257
This commit is contained in:
parent
9d3bb25b2d
commit
abb99360d3
@ -1798,7 +1798,7 @@ static bool service_shall_restart(Service *s, const char **reason) {
|
||||
return false;
|
||||
|
||||
case SERVICE_RESTART_ALWAYS:
|
||||
return true;
|
||||
return s->result != SERVICE_SKIP_CONDITION;
|
||||
|
||||
case SERVICE_RESTART_ON_SUCCESS:
|
||||
return s->result == SERVICE_SUCCESS;
|
||||
|
10
test/units/testsuite-51-repro-3.service
Normal file
10
test/units/testsuite-51-repro-3.service
Normal file
@ -0,0 +1,10 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Unit]
|
||||
Description=Issue 22257 Repro with Restart=always
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
ExecCondition=/bin/false
|
||||
ExecStart=sleep 100
|
||||
RestartSec=1
|
@ -5,9 +5,11 @@ set -o pipefail
|
||||
|
||||
systemctl start testsuite-51-repro-1
|
||||
systemctl start testsuite-51-repro-2
|
||||
systemctl start testsuite-51-repro-3
|
||||
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" ]]
|
||||
[[ "$(systemctl show testsuite-51-repro-3 -P NRestarts)" == "0" ]]
|
||||
|
||||
touch /testok
|
||||
|
Loading…
x
Reference in New Issue
Block a user