Merge pull request #27244 from bluca/uphold_retry

Uphold/StopWhenUnneeded/BindsTo: add retry timer on rate limit
This commit is contained in:
Luca Boccassi
2023-04-13 21:33:06 +01:00
committed by GitHub
10 changed files with 132 additions and 6 deletions
@@ -0,0 +1,9 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Failed Dependency Unit
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "if [ -f /tmp/testsuite-57-retry-fail ]; then exit 0; else exit 1; fi"
Restart=no
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Upheld Unit
Requires=testsuite-57-retry-fail.service
After=testsuite-57-retry-fail.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/echo ok
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Upholding Unit
Upholds=testsuite-57-retry-upheld.service
[Service]
ExecStart=/bin/sleep infinity
+27
View File
@@ -26,6 +26,33 @@ done
systemctl stop testsuite-57-uphold.service
# Idea is this:
# 1. we start testsuite-57-retry-uphold.service
# 2. which through Uphold= starts testsuite-57-retry-upheld.service
# 3. which through Requires= starts testsuite-57-retry-fail.service
# 4. which fails as /tmp/testsuite-57-retry-fail does not exist, so testsuite-57-retry-upheld.service
# is no longer restarted
# 5. we create /tmp/testsuite-57-retry-fail
# 6. now testsuite-57-retry-upheld.service will be restarted since upheld, and its dependency will
# be satisfied
rm -f /tmp/testsuite-57-retry-fail
systemctl start testsuite-57-retry-uphold.service
while ! systemctl is-failed testsuite-57-retry-fail.service ; do
sleep .5
done
systemctl is-active testsuite-57-retry-upheld.service && { echo 'unexpected success'; exit 1; }
touch /tmp/testsuite-57-retry-fail
while ! systemctl is-active testsuite-57-retry-upheld.service ; do
sleep .5
done
systemctl stop testsuite-57-retry-uphold.service testsuite-57-retry-fail.service testsuite-57-retry-upheld.service
# Idea is this:
# 1. we start testsuite-57-prop-stop-one.service
# 2. which through Wants=/After= pulls in testsuite-57-prop-stop-two.service as well