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
This commit is contained in:
Slawek Kaplonski 2022-05-04 16:34:20 +02:00
parent cbd4ffe653
commit aaa8ce1a6d

View File

@ -27,8 +27,7 @@ fi
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() {
@ -40,6 +39,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
@ -55,6 +60,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}"