From 3670032a436200c35d84c17505101d651dbe2018 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Tue, 31 Aug 2021 15:47:14 +0200 Subject: [PATCH] Wrap stopping podman -t with systemd timeouts Currently with KillMode=none, if podman -t hangs, the command repeats leaving the process and its cgroup around. But if a stop/start command hangs, we should not start another one. Instead time it out properly via TimeoutStopSec set to the 2x of the timeout given to the managed podman action. Then if it expires, kill its cgroup all the way (KillMode=control-group is a default) before rerunning the same operation. Also note that using KilMode process is not recommended by systemd man pages. Increase the grace stop timeout defaults 10->42s to align it with: https://github.com/containers/podman/pull/8889 Closes-bug: #1945791 Change-Id: Iefe861f91cefe2a9cf773cae98b2440566ae8b5e Signed-off-by: Bogdan Dobrelya (cherry picked from commit badd5a3c10f0af9e1c69a9b88064e743a36d4f53) --- .../tripleo_container_manage/templates/systemd-service.j2 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tripleo_ansible/roles/tripleo_container_manage/templates/systemd-service.j2 b/tripleo_ansible/roles/tripleo_container_manage/templates/systemd-service.j2 index 7513a5d76..2410d3a6b 100644 --- a/tripleo_ansible/roles/tripleo_container_manage/templates/systemd-service.j2 +++ b/tripleo_ansible/roles/tripleo_container_manage/templates/systemd-service.j2 @@ -13,10 +13,10 @@ ExecReload=/usr/bin/podman kill --signal HUP {{ lookup('dict', container_data_un {% if lookup('dict', container_data_unit).value.pre_stop_exec is defined %} ExecStop=-/usr/bin/podman exec {{ lookup('dict', container_data_unit).key }} {{ lookup('dict', container_data_unit).value.pre_stop_exec }} {% endif %} -ExecStop=/usr/bin/podman stop -t {{ lookup('dict', container_data_unit).value.stop_grace_period | default(10) | int }} {{ lookup('dict', container_data_unit).key }} -ExecStopPost=/usr/bin/podman stop -t {{ lookup('dict', container_data_unit).value.stop_grace_period | default(10) | int }} {{ lookup('dict', container_data_unit).key }} +ExecStop=/usr/bin/podman stop -t {{ lookup('dict', container_data_unit).value.stop_grace_period | default(42) | int }} {{ lookup('dict', container_data_unit).key }} +ExecStopPost=/usr/bin/podman stop -t {{ lookup('dict', container_data_unit).value.stop_grace_period | default(42) | int }} {{ lookup('dict', container_data_unit).key }} SuccessExitStatus=137 142 143 -KillMode=none +TimeoutStopSec={{ 2*lookup('dict', container_data_unit).value.stop_grace_period | default(42) | int }} Type=forking PIDFile=/var/run/{{ lookup('dict', container_data_unit).key }}.pid {% if lookup('dict', container_data_unit).value.systemd_exec_flags is defined %}