mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
core: serialize and deserialize unit start ratelimits
The logic is taken from dump ratelimit: if the config changes, we discard the counters. This allows the user apply new limits and "start from scratch" in that case. This actually makes StartLimitIntervalSec=infinity (or with a large interval) work as expected, because the counter is maintained even if daemon-reload operations are interleaved.
This commit is contained in:
committed by
Luca Boccassi
parent
07a6647abb
commit
6ef512c0bb
@@ -140,6 +140,8 @@ int unit_serialize_state(Unit *u, FILE *f, FDSet *fds, bool switching_root) {
|
|||||||
(void) serialize_dual_timestamp(f, "condition-timestamp", &u->condition_timestamp);
|
(void) serialize_dual_timestamp(f, "condition-timestamp", &u->condition_timestamp);
|
||||||
(void) serialize_dual_timestamp(f, "assert-timestamp", &u->assert_timestamp);
|
(void) serialize_dual_timestamp(f, "assert-timestamp", &u->assert_timestamp);
|
||||||
|
|
||||||
|
(void) serialize_ratelimit(f, "start-ratelimit", &u->start_ratelimit);
|
||||||
|
|
||||||
if (dual_timestamp_is_set(&u->condition_timestamp))
|
if (dual_timestamp_is_set(&u->condition_timestamp))
|
||||||
(void) serialize_bool(f, "condition-result", u->condition_result);
|
(void) serialize_bool(f, "condition-result", u->condition_result);
|
||||||
|
|
||||||
@@ -343,6 +345,10 @@ int unit_deserialize_state(Unit *u, FILE *f, FDSet *fds) {
|
|||||||
(void) deserialize_dual_timestamp(v, &u->assert_timestamp);
|
(void) deserialize_dual_timestamp(v, &u->assert_timestamp);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
} else if (streq(l, "start-ratelimit")) {
|
||||||
|
deserialize_ratelimit(&u->start_ratelimit, l, v);
|
||||||
|
continue;
|
||||||
|
|
||||||
} else if (MATCH_DESERIALIZE("condition-result", l, v, parse_boolean, u->condition_result))
|
} else if (MATCH_DESERIALIZE("condition-result", l, v, parse_boolean, u->condition_result))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ set -o pipefail
|
|||||||
mkdir /run/systemd/system/systemd-journald.service.d
|
mkdir /run/systemd/system/systemd-journald.service.d
|
||||||
MACHINE_ID="$(</etc/machine-id)"
|
MACHINE_ID="$(</etc/machine-id)"
|
||||||
|
|
||||||
|
# Reset the start-limit counters, as we're going to restart journald a couple of times
|
||||||
|
systemctl reset-failed systemd-journald.service
|
||||||
|
|
||||||
for c in NONE XZ LZ4 ZSTD; do
|
for c in NONE XZ LZ4 ZSTD; do
|
||||||
cat >/run/systemd/system/systemd-journald.service.d/compress.conf <<EOF
|
cat >/run/systemd/system/systemd-journald.service.d/compress.conf <<EOF
|
||||||
[Service]
|
[Service]
|
||||||
@@ -35,4 +38,5 @@ done
|
|||||||
rm /run/systemd/system/systemd-journald.service.d/compress.conf
|
rm /run/systemd/system/systemd-journald.service.d/compress.conf
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl restart systemd-journald.service
|
systemctl restart systemd-journald.service
|
||||||
|
systemctl reset-failed systemd-journald.service
|
||||||
journalctl --rotate
|
journalctl --rotate
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ do
|
|||||||
# Make sure we are in a consistent state, e.g. not already active before we start
|
# Make sure we are in a consistent state, e.g. not already active before we start
|
||||||
systemctl stop systemd-integritysetup@"${DM_NAME}".service || exit 1
|
systemctl stop systemd-integritysetup@"${DM_NAME}".service || exit 1
|
||||||
systemctl start systemd-integritysetup@"${DM_NAME}".service || exit 1
|
systemctl start systemd-integritysetup@"${DM_NAME}".service || exit 1
|
||||||
|
# Reset the start-limit counters, as we're going to restart the service a couple of times
|
||||||
|
systemctl reset-failed systemd-integritysetup@"${DM_NAME}".service
|
||||||
|
|
||||||
# Check the signature on the FS to ensure we can retrieve it and that is matches
|
# Check the signature on the FS to ensure we can retrieve it and that is matches
|
||||||
if [ -e "${FULL_DM_DEV_NAME}" ]; then
|
if [ -e "${FULL_DM_DEV_NAME}" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user