From a5f5959574f98c766d3dab7cf9afdf2d6c0e7f5d Mon Sep 17 00:00:00 2001 From: Kyle Sessions Date: Sat, 4 May 2024 00:55:35 +0000 Subject: [PATCH 1/2] systemd: skip automatic restart when a JOB_STOP job is pending Signed-off-by: Kyle Sessions --- Dockerfile | 1 + ...start-when-a-JOB_STOP-job-is-pending.patch | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 systemd-patches/9504-core-skip-restart-when-a-JOB_STOP-job-is-pending.patch diff --git a/Dockerfile b/Dockerfile index cd2a2f5..d3d7a77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,6 +76,7 @@ RUN last_patch=$(awk '/^Patch[0-9]+/ { line = NR } END { print line }' systemd.s echo 'Patch9501: 9501-cgroup-util-accept-cgroup-hierarchy-base-as-option.patch'; \ echo 'Patch9502: 9502-core-move-initialization-of-.slice-and-init.scope-in.patch'; \ echo 'Patch9503: 9503-core-drop-.slice-from-shipped-units.patch'; \ + echo 'Patch9504: 9504-core-skip-restart-when-a-JOB_STOP-job-is-pending.patch'; \ echo ; \ } >>systemd.mod.spec; \ tail -n+$((last_patch + 1)) systemd.spec >>systemd.mod.spec; \ diff --git a/systemd-patches/9504-core-skip-restart-when-a-JOB_STOP-job-is-pending.patch b/systemd-patches/9504-core-skip-restart-when-a-JOB_STOP-job-is-pending.patch new file mode 100644 index 0000000..14eb44d --- /dev/null +++ b/systemd-patches/9504-core-skip-restart-when-a-JOB_STOP-job-is-pending.patch @@ -0,0 +1,52 @@ +From c972880640ee19e89ce9265d8eae1b3aae190332 Mon Sep 17 00:00:00 2001 +From: Franck Bui +Date: Fri, 18 Feb 2022 10:06:24 +0100 +Subject: [PATCH] core: really skip automatic restart when a JOB_STOP job is + pending + +It's not clear why we rescheduled a service auto restart while a stop job for +the unit was pending. The comment claims that the unit shouldn't be restarted +but the code did reschedule an auto restart meanwhile. + +In practice that was rarely an issue because the service waited for the next +auto restart to be rescheduled, letting the queued stop job to be proceed and +service_stop() to be called preventing the next restart to complete. + +However when RestartSec=0, the timer expired right away making PID1 to +reschedule the unit again, making the timer expired right away... and so +on. This busy loop prevented PID1 to handle any queued jobs (and hence giving +no chance to the start rate limiting to trigger), which made the busy loop last +forever. + +This patch breaks this loop by skipping the reschedule of the unit auto restart +and hence not depending on the value of u->restart_usec anymore. + +Fixes: #13667 + +[kssessio: backport to v219] +Signed-off-by: Kyle Sessions +--- + src/core/service.c | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +diff --git a/src/core/service.c b/src/core/service.c +index 15e29be..fa2af05 100644 +--- a/src/core/service.c ++++ b/src/core/service.c +@@ -1622,12 +1622,7 @@ static void service_enter_restart(Service *s) { + + if (UNIT(s)->job && UNIT(s)->job->type == JOB_STOP) { + /* Don't restart things if we are going down anyway */ +- log_unit_info(UNIT(s)->id, "Stop job pending for unit, delaying automatic restart."); +- +- r = service_arm_timer(s, s->restart_usec); +- if (r < 0) +- goto fail; +- ++ log_unit_info(UNIT(s)->id, "Stop job pending for unit, skipping automatic restart."); + return; + } + +-- +2.40.1 + From 7dc0d268c7025acda169be2c84b978ab820595d2 Mon Sep 17 00:00:00 2001 From: Kyle Sessions Date: Sat, 4 May 2024 00:58:07 +0000 Subject: [PATCH 2/2] Version v0.11.8 Signed-off-by: Kyle Sessions --- CHANGELOG.md | 7 +++++++ VERSION | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72a8080..1928d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 0.11.8 + +* Added systemd skip automatic restart when a JOB_STOP job is pending patch. ([#97]) +* Rebuilt to get the latest AL2 updates. + +[#97]: https://github.com/bottlerocket-os/bottlerocket-admin-container/pull/97 + # 0.11.7 * Rebuilt to get the latest AL2 updates. diff --git a/VERSION b/VERSION index 97bd28b..bf2a1db 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.11.7 +v0.11.8