Browse Source

wait for container to terminate before returning from systemctl stop

main
Nicolas Massé 2 weeks ago
parent
commit
7570929e77
  1. 4
      cookbooks/base/Makefile
  2. 3
      cookbooks/base/dropins/container.d/10-wait-teardown.conf
  3. 17
      cookbooks/vllm/dropins/vllm-model@.container.d/20-no-wait-teardown.conf
  4. 4
      scripts/common.mk

4
cookbooks/base/Makefile

@ -23,9 +23,9 @@ pre-requisites::
install-actions-pre:: install-actions-pre::
@set -Eeuo pipefail; \ @set -Eeuo pipefail; \
run() { echo $$*; "$$@"; }; \ run() { echo $$*; "$$@"; }; \
if ! getent group itix-svc >/dev/null; then \ if ! getent group 10000 >/dev/null; then \
run groupadd -g 10000 itix-svc; \ run groupadd -g 10000 itix-svc; \
fi ; \ 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; \ run useradd -u 10000 -g 10000 -M -d /tmp -c "ITIX Misc. Services" itix-svc; \
fi fi

3
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'

17
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=

4
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)) 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 # 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_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_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_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)) TARGET_EXAMPLES_SYSTEMD_DROPINS_FILES = $(patsubst dropins/%, $(TARGET_CHROOT)/etc/systemd/system/%, $(EXAMPLES_SYSTEMD_DROPINS_FILES))

Loading…
Cancel
Save