From d6098ae57bbef79d2ab6c9edffd7b2edd9cb52ab Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Wed, 4 May 2022 16:34:20 +0200 Subject: [PATCH] Remove sidecar containers after SIGTERM is send to stop them Previously neutron's sidecar containers were removed only when kill-script was called with SIGKILL signal, if it was SIGTERM, then container was stopped but not removed. Now kill-script script will try to delete stopped container in both cases, when SIGKILL and SIGTERM is send to the script. Closes: rhbz#2080811 Change-Id: I79e70731779067093f6de2879b98cfe8f2b7a89f (cherry picked from commit aaa8ce1a6d117f72911ea2e19fa3545c17da3a20) --- deployment/neutron/kill-script | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/deployment/neutron/kill-script b/deployment/neutron/kill-script index 4f5c6ad573..bc274c7396 100644 --- a/deployment/neutron/kill-script +++ b/deployment/neutron/kill-script @@ -36,8 +36,7 @@ CLI='echo noop' kill_container() { add_date "Stopping container $1 ($2)" $CLI stop $2 - add_date "Deleting container $1 ($2)" - $CLI rm $2 + delete_container $1 $2 } signal_container() { @@ -49,6 +48,12 @@ signal_container() { $CLI kill --signal $SIGNAL $2 } +delete_container() { + add_date "Deleting container $1 ($2)" + $CLI rm $2 || echo "Deleting container $1 ($2) failed" +} + + {% raw -%} if [ -f /proc/$PID/cgroup ]; then # Get container ID based on process cgroups @@ -64,6 +69,7 @@ if [ -f /proc/$PID/cgroup ]; then ;; 15) signal_container $CT_NAME $CT_ID 15 + delete_container $CT_NAME $CT_ID ;; *) add_date "Unknown action ${SIG} for ${CT_NAME} ${CT_ID}"