From 70801b3d714b067d64744697433c5841926dad4d Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Mon, 23 Aug 2021 17:49:47 +0200 Subject: generate systemd: custom stop signal Commit 9ac5267598c3 changed the type of the generated systemd units from forking to notify. Parts of these changes was also removing the need to pass any information via the file system (e.g., PIDFILE, container ID). That in turn implies that systemd takes care of stopping the container. By default, systemd first sends a SIGTERM and after a certain timeout, it'll send a SIGKILL. That's pretty much what Podman is doing, unless the container was created with a custom stop signal which is the case when the --stop-signal flag was used or systemd is mounted. Account for that by using systemd's KillSignal option which allows for changing SIGTERM to another signal. Also make sure that we're using the correct timeout for units generated with --new. Fixes: #11304 Signed-off-by: Valentin Rothberg --- test/system/250-systemd.bats | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index ee951ff21..37e5fa2f9 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -125,4 +125,17 @@ function service_cleanup() { service_cleanup } +@test "podman generate systemd - stop-signal" { + cname=$(random_string) + run_podman create --name $cname --stop-signal=42 $IMAGE + run_podman generate systemd --new $cname + is "$output" ".*KillSignal=42.*" "KillSignal is set" + + # Regression test for #11304: systemd wants a custom stop-signal. + run_podman rm -f $cname + run_podman create --name $cname --systemd=true $IMAGE systemd + run_podman generate systemd --new $cname + is "$output" ".*KillSignal=37.*" "KillSignal is set" +} + # vim: filetype=sh -- cgit v1.2.3-54-g00ecf