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 aaa8ce1a6d)
This commit is contained in:
Slawek Kaplonski 2022-05-04 16:34:20 +02:00
parent 2174e171d1
commit 2eca7177e4
1 changed files with 8 additions and 2 deletions

View File

@ -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}"