From 4f9b3146a19b342c232862543c78460f35613f11 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 27 Mar 2025 10:40:04 +0100 Subject: [PATCH 1/4] package/finit: bump to v4.11 ChangeLog: https://github.com/troglobit/finit/releases/tag/4.11 Fixes #980 Signed-off-by: Joachim Wiberg --- package/finit/finit.hash | 2 +- package/finit/finit.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package/finit/finit.hash b/package/finit/finit.hash index 8c6130ce..c9a94f26 100644 --- a/package/finit/finit.hash +++ b/package/finit/finit.hash @@ -1,5 +1,5 @@ # From https://github.com/troglobit/finit/releases/ -sha256 da14f5f05f595e15abc73bbacabfb55e8e1a4c40fc6ca6ab294be34ea437cc82 finit-4.10.tar.gz +sha256 7e49a3df58c5aedfff9537b7ff34b9238fc28b523d4dbacc316d606c7af5e335 finit-4.11.tar.gz # Locally calculated sha256 2fd62c0fe6ea6d1861669f4c87bda83a0b5ceca64f4baa4d16dd078fbd218c14 LICENSE diff --git a/package/finit/finit.mk b/package/finit/finit.mk index e3060497..96108029 100644 --- a/package/finit/finit.mk +++ b/package/finit/finit.mk @@ -4,7 +4,7 @@ # ################################################################################ -FINIT_VERSION = 4.10 +FINIT_VERSION = 4.11 FINIT_SITE = https://github.com/troglobit/finit/releases/download/$(FINIT_VERSION) FINIT_LICENSE = MIT FINIT_LICENSE_FILES = LICENSE From 910749bab126a05e44fb0007d6030f006c46e73e Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 28 Mar 2025 06:42:21 +0100 Subject: [PATCH 2/4] board/common: send SIGTERM when container is in its setup phase When stopping a container that is (stuck) in setup state, e.g., fetching its container image, we need to send SIGTERM to the container wrapper script rather than forwarding the 'stop' command to podman. With this fix, and the Finit upgrade, there is no longer a 10 second timeout before Finit sends SIGKILL to the PID. Instead, the script now immediately react to the initial SIGTERM. Related to issue #980 Signed-off-by: Joachim Wiberg --- board/common/rootfs/usr/sbin/container | 46 +++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/board/common/rootfs/usr/sbin/container b/board/common/rootfs/usr/sbin/container index 7905b712..5561729c 100755 --- a/board/common/rootfs/usr/sbin/container +++ b/board/common/rootfs/usr/sbin/container @@ -39,6 +39,11 @@ err() [ "$rc" -eq 0 ] || exit "$rc" } +pidfn() +{ + echo "/run/containers/${1}.pid" +} + check() { file=$1 @@ -235,7 +240,7 @@ create() args="$args --read-only --replace --quiet --cgroup-parent=containers $caps" args="$args --restart=$restart --systemd=false --tz=local $privileged" args="$args $vol $mount $hostname $entrypoint $env $port $logging" - pidfn=/run/container:${name}.pid + pidfile=/run/container:${name}.pid [ -n "$quiet" ] || log "---------------------------------------" [ -n "$quiet" ] || log "Got name: $name image: $image" @@ -258,8 +263,8 @@ create() fi # shellcheck disable=SC2048 - log "podman create --name $name --conmon-pidfile=$pidfn $args $image $*" - if podman create --name "$name" --conmon-pidfile="$pidfn" $args "$image" $*; then + log "podman create --name $name --conmon-pidfile=$pidfile $args $image $*" + if podman create --name "$name" --conmon-pidfile="$pidfile" $args "$image" $*; then [ -n "$quiet" ] || log "Successfully created container $name from $image" [ -n "$manual" ] || start "$name" @@ -340,6 +345,24 @@ wrap() { name=$1 cmd=$2 + pidfile=$(pidfn "$name") + + # Containers have three phases: setup, running, and teardown. + + # The setup phase may run forever in the background trying to fetch + # the image. It saves its PID in /run/containers/${name}.pid + if [ "$cmd" = "stop" ] && [ -f "$pidfile" ]; then + pid=$(cat "$pidfile") + + # Check if setup is still running ... + if kill -0 "$pid" 2>/dev/null; then + kill "$pid" + wait "$pid" 2>/dev/null + fi + + rm -f "$pidfile" + return 0 + fi # Skip "echo $name" from podman start in log podman "$cmd" "$name" >/dev/null @@ -375,7 +398,14 @@ netrestart() cleanup() { + pidfile=$(pidfn "$name") + log "Received signal, exiting." + if [ -n "$name" ] && [ -f "$pidfile" ]; then + log "$name: in setup phase, removing $pidfile ..." + rm -f "$pidfile" + fi + exit 1 } @@ -574,7 +604,7 @@ if [ -n "$cmd" ]; then shift fi -trap cleanup INT TERM +trap cleanup INT HUP TERM case $cmd in # Does not work atm., cannot attach to TTY because @@ -710,6 +740,12 @@ case $cmd in [ -n "$name" ] || err 1 "setup: missing container name." script=/run/containers/${name}.sh [ -x "$script" ] || err 1 "setup: $script does not exist or is not executable." + + # Save our PID in case we get stuck here and someone wants to + # stop us, e.g., due to reconfiguration or reboot. + pidfile=$(pidfn "${name}") + echo $$ > "$pidfile" + while ! "$script"; do log "${name}: setup failed, waiting for network changes ..." read -t 60 _ < <(ip monitor address route) @@ -719,6 +755,8 @@ case $cmd in log "${name}: retrying ..." sleep 2 done + + rm -f "$pidfile" ;; shell) if [ -z "$name" ]; then From 7253be761916fe426b9f0be16b5d197e5105b789 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 28 Mar 2025 06:56:56 +0100 Subject: [PATCH 3/4] Allow writing to the ttyd console after Buildroot bump Fixes #990 Signed-off-by: Joachim Wiberg --- board/common/rootfs/etc/finit.d/available/ttyd.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/common/rootfs/etc/finit.d/available/ttyd.conf b/board/common/rootfs/etc/finit.d/available/ttyd.conf index 58205b2f..8c36d515 100644 --- a/board/common/rootfs/etc/finit.d/available/ttyd.conf +++ b/board/common/rootfs/etc/finit.d/available/ttyd.conf @@ -1 +1 @@ -service [2345] ttyd -i lo -p 8001 login -- Web terminal daemon (ttyd) +service [2345] ttyd -i lo -W -p 8001 login -- Web terminal daemon (ttyd) From 18659fd45a643b1bc4e27ffc7e5ab56d41fa1a5e Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 28 Mar 2025 07:01:40 +0100 Subject: [PATCH 4/4] doc: update ChangeLog for v25.03 Signed-off-by: Joachim Wiberg --- doc/ChangeLog.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index a15db37b..b7c1280d 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -6,7 +6,9 @@ All notable changes to the project are documented in this file. [v25.03.0][UNRELEASED] - ------------------------- -**News:** this release is the first with the new Buildroot LTS (2025.02) + +> [!IMPORTANT] +> This release is the first with the new Buildroot 2025.02 (LTS) ### Changes - Upgrade Linux kernel to 6.12.21 (LTS) @@ -14,6 +16,10 @@ All notable changes to the project are documented in this file. ### Fixes - Fix #964: YANG schema warning in syslog: missing 'monitor' node for lag + - Fix #980: the system fails to reboot when a container is (stuck), for + whatever reason, in its 'setup' state + - Fix #990: web console, ttyd service, stopped working after upgrade to + Buildroot 2025.02, caused by new (missing) option `--writable` [v25.02.0][] - 2025-03-04