Skip to content

Commit

Permalink
Merge pull request #89 from kelvinfan001/rate-limit
Browse files Browse the repository at this point in the history
{issuegen,motdgen}.service: `sleep 1` before we start generating
  • Loading branch information
kelvinfan001 authored Nov 20, 2020
2 parents 1e95fe5 + ba46ea3 commit 39eef27
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/kola/basic/test-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ ok "symlink"
# If SSH keys are present, check that SSH keys snippets were generated by
# `gensnippet_ssh_keys` and shown by `agetty`.
if test -n "$(find /etc/ssh -name 'ssh_host_*_key' -print -quit)"; then
sleep 2
faketty agetty_output.txt agetty --show-issue
assert_file_has_content agetty_output.txt 'SSH host key:*'
ok "gensnippet_ssh_keys"
Expand All @@ -44,9 +45,26 @@ fi
# Check that a new issue snippet is generated when a .issue file is dropped into
# the issue run directory.
echo 'foo' > ${ISSUE_RUN_SNIPPETS_PATH}/10_foo.issue
sleep 1
sleep 2
faketty agetty_output.txt agetty --show-issue
assert_file_has_content agetty_output.txt 'foo'
ok "display new issue snippet"
ok "display new single issue snippet"

# Check that a large burst of .issue files dropped into the issue run directory
# will all get displayed, and that we don't hit any systemd 'start-limit-hit'
# failures
for i in {1..150};
do
echo "Issue snippet: $i" > ${ISSUE_RUN_SNIPPETS_PATH}/${i}_spam.issue
done
sleep 2
faketty agetty_output.txt agetty --show-issue
for i in {1..150};
do
assert_file_has_content agetty_output.txt "Issue snippet: $i"
done
systemctl status ${PKG_NAME}-issuegen.path > issuegen_status.txt
assert_not_file_has_content issuegen_status.txt "unit-start-limit-hit"
ok "display burst of new issue snippets"

tap_finish
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ After=console-login-helper-messages-issuegen.path
# Only run if source directories have `.issue` files.
ConditionPathExistsGlob=|/run/console-login-helper-messages/issue.d/*.issue
ConditionPathExistsGlob=|/etc/console-login-helper-messages/issue.d/*.issue
# Set rate limit to twice per second just in case. With `ExecStartPre=` below,
# we should not have any systemd 'start-limit-hit' failures.
StartLimitIntervalSec=1
StartLimitBurst=2

[Service]
Type=oneshot
Expand All @@ -16,6 +20,11 @@ Type=oneshot
# `start` on this service after it has exited once before does not have any
# effect).
RemainAfterExit=no
# See https://github.com/coreos/console-login-helper-messages/issues/87
# We want to avoid service start limits and throttle the rate at
# which we regenerate. This ensures the service starts at most once
# per second.
ExecStartPre=sleep 1
ExecStart=/usr/libexec/console-login-helper-messages/issuegen

[Install]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ After=console-login-helper-messages-motdgen.path
# Only run if source directories have `.motd` files.
ConditionPathExistsGlob=|/run/console-login-helper-messages/motd.d/*.motd
ConditionPathExistsGlob=|/etc/console-login-helper-messages/motd.d/*.motd
# Set rate limit to twice per second just in case. With `ExecStartPre=` below,
# we should not have any systemd 'start-limit-hit' failures.
StartLimitIntervalSec=1
StartLimitBurst=2

[Service]
Type=oneshot
Expand All @@ -15,6 +19,11 @@ Type=oneshot
# `start` on this service after it has exited once before does not have any
# effect).
RemainAfterExit=no
# See https://github.com/coreos/console-login-helper-messages/issues/87
# We want to avoid service start limits and throttle the rate at
# which we regenerate. This ensures the service starts at most once
# per second.
ExecStartPre=sleep 1
ExecStart=/usr/libexec/console-login-helper-messages/motdgen

[Install]
Expand Down

0 comments on commit 39eef27

Please sign in to comment.