From 7570929e77aaa96aa2f7fcff5c8e93f1b123027a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Thu, 23 Jul 2026 18:35:15 +0000 Subject: [PATCH] wait for container to terminate before returning from systemctl stop --- cookbooks/base/Makefile | 4 ++-- .../dropins/container.d/10-wait-teardown.conf | 3 +++ .../20-no-wait-teardown.conf | 17 +++++++++++++++++ scripts/common.mk | 4 ++-- 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 cookbooks/base/dropins/container.d/10-wait-teardown.conf create mode 100644 cookbooks/vllm/dropins/vllm-model@.container.d/20-no-wait-teardown.conf diff --git a/cookbooks/base/Makefile b/cookbooks/base/Makefile index 4675d85..ce05908 100644 --- a/cookbooks/base/Makefile +++ b/cookbooks/base/Makefile @@ -23,9 +23,9 @@ pre-requisites:: install-actions-pre:: @set -Eeuo pipefail; \ run() { echo $$*; "$$@"; }; \ - if ! getent group itix-svc >/dev/null; then \ + if ! getent group 10000 >/dev/null; then \ run groupadd -g 10000 itix-svc; \ fi ; \ - if ! getent passwd itix-svc >/dev/null; then \ + if ! getent passwd 10000 >/dev/null; then \ run useradd -u 10000 -g 10000 -M -d /tmp -c "ITIX Misc. Services" itix-svc; \ fi diff --git a/cookbooks/base/dropins/container.d/10-wait-teardown.conf b/cookbooks/base/dropins/container.d/10-wait-teardown.conf new file mode 100644 index 0000000..55743cf --- /dev/null +++ b/cookbooks/base/dropins/container.d/10-wait-teardown.conf @@ -0,0 +1,3 @@ +[Service] +# Wait for the container to be removed before returning from stop +ExecStopPost=/bin/sh -c 'cid=$(podman ps -aq --filter label=PODMAN_SYSTEMD_UNIT=%n); [ -n "$cid" ] && podman wait --ignore --condition removing "$cid"; exit 0' diff --git a/cookbooks/vllm/dropins/vllm-model@.container.d/20-no-wait-teardown.conf b/cookbooks/vllm/dropins/vllm-model@.container.d/20-no-wait-teardown.conf new file mode 100644 index 0000000..a7236b0 --- /dev/null +++ b/cookbooks/vllm/dropins/vllm-model@.container.d/20-no-wait-teardown.conf @@ -0,0 +1,17 @@ +[Service] +# Opt these model units OUT of the global wait-teardown drop-in shipped by the +# "base" cookbook (container.d/10-wait-teardown.conf), which makes `systemctl +# stop` block until Podman has finished tearing the container down. +# +# That global wait keeps a unit in the `deactivating` state for the whole +# teardown. It is the wrong behavior for the model units: llmsnap owns their +# lifecycle and drives rapid stop/start swaps over D-Bus, keying off +# `systemctl is-active` (which flips to inactive as soon as deactivation starts) +# and off the exit code of `systemctl stop` (its cmdStop). A widened +# `deactivating` window lets a subsequent `start` cancel the still-pending stop +# job, so cmdStop returns non-zero, the swap fails and `make test` fails with it. +# +# An empty assignment clears the inherited ExecStopPost (the global wait). +# Quadlet re-emits its own `podman rm` cleanup after the drop-ins, and the models +# always run with --rm, so the container is still removed — we only drop the wait. +ExecStopPost= diff --git a/scripts/common.mk b/scripts/common.mk index 640fee3..535269e 100644 --- a/scripts/common.mk +++ b/scripts/common.mk @@ -115,8 +115,8 @@ TARGET_EXAMPLES_PROFILED_FILES = $(patsubst profile.d/examples/%, $(TARGET_CHROO TARGET_EXAMPLES_POLKITD_FILES = $(patsubst polkit-rules.d/examples/%, $(TARGET_CHROOT)/etc/polkit-1/rules.d/60-%, $(EXAMPLES_POLKITD_FILES)) # Example quadlet and systemd drop-ins files -EXAMPLES_QUADLET_DROPINS_FILES := $(shell if [ -d dropins ]; then find dropins -mindepth 1 -type f | grep -E '\.(container|volume|network|pod|build|image)\.d/' 2>/dev/null; fi) -EXAMPLES_SYSTEMD_DROPINS_FILES := $(shell if [ -d dropins ]; then find dropins -mindepth 1 -type f | grep -E '\.(service|target|timer|mount)\.d/' 2>/dev/null; fi) +EXAMPLES_QUADLET_DROPINS_FILES := $(shell if [ -d dropins ]; then find dropins -mindepth 1 -type f | grep -E '\.?(container|volume|network|pod|build|image)\.d/' 2>/dev/null; fi) +EXAMPLES_SYSTEMD_DROPINS_FILES := $(shell if [ -d dropins ]; then find dropins -mindepth 1 -type f | grep -E '\.?(service|target|timer|mount)\.d/' 2>/dev/null; fi) TARGET_EXAMPLES_QUADLET_DROPINS_FILES = $(patsubst dropins/%, $(TARGET_CHROOT)/etc/containers/systemd/%, $(EXAMPLES_QUADLET_DROPINS_FILES)) TARGET_EXAMPLES_SYSTEMD_DROPINS_FILES = $(patsubst dropins/%, $(TARGET_CHROOT)/etc/systemd/system/%, $(EXAMPLES_SYSTEMD_DROPINS_FILES))