Merge pull request #22259 from bluca/exec_cond_restart
core: do not restart a service with Restart=always when ExecCondition fails
This commit is contained in:
@@ -9,6 +9,9 @@ CHANGES WITH 251:
|
||||
can still be used by explicitly configuring RouteTable= setting in
|
||||
.netdev files.
|
||||
|
||||
* Services with Restart=always and a failing ExecCondition= will no longer
|
||||
be restarted, to bring ExecCondition= in line with Condition*= settings.
|
||||
|
||||
CHANGES WITH 250:
|
||||
|
||||
* Support for encrypted and authenticated credentials has been added.
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user