Merge "Remove sidecar containers after SIGTERM is send to stop them"

This commit is contained in:
Zuul 2022-05-06 11:24:27 +00:00 committed by Gerrit Code Review
commit b9ceb972ce
1 changed files with 8 additions and 2 deletions

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