From 23e939846d4ea3507fba0fc51c0b3c4e34c6d6bd Mon Sep 17 00:00:00 2001 From: Stepan Blyshchak <38952541+stepanblyschak@users.noreply.github.com> Date: Wed, 13 Apr 2022 17:37:43 +0300 Subject: [PATCH] [scripts/fast-reboot] Shutdown remaining containers through systemd (#2133) The current implementation has two issues: 1. In case containers from "docker ps" output are ordered in a way that database is first in the list, the "systemctl stop database" followed by "docker kill database" will stop all other containers through systemd and ruin this optimization 2. After "docker kill database" there are lots of errors from daemons like hostcfgd, system-healthd, caclmgrd, etc. Also it causes those daemons to hang when received SIGTERM making a delay on following "systemctl stop database". In the new implementation, services are implicitly stopped by systemd in the order that is correct. If a certain container needs an optimization that will kill the container instead of stopping it the container may implement this optimization in its /usr/local/bin/*.sh script. It is also more optimal since independent services might be stopped in parallel. - What I did Stop services using systemd - How I did it Stop services using systemd - How to verify it Run warm-reboot. Signed-off-by: Stepan Blyschak --- scripts/fast-reboot | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/scripts/fast-reboot b/scripts/fast-reboot index 5749e3745a..d5b6e204bd 100755 --- a/scripts/fast-reboot +++ b/scripts/fast-reboot @@ -738,26 +738,6 @@ for service in ${SERVICES_TO_STOP}; do fi done -# Kill other containers to make the reboot faster -# We call `docker kill ...` to ensure the container stops as quickly as possible, -# then immediately call `systemctl stop ...` to prevent the service from -# restarting the container automatically. -debug "Stopping all remaining containers ..." -if test -f /usr/local/bin/ctrmgr_tools.py -then - /usr/local/bin/ctrmgr_tools.py kill-all -else - for CONTAINER_NAME in $(docker ps --format '{{.Names}}'); do - CONTAINER_STOP_RC=0 - docker kill $CONTAINER_NAME &> /dev/null || CONTAINER_STOP_RC=$? - systemctl stop $CONTAINER_NAME || debug "Ignore stopping $CONTAINER_NAME error $?" - if [[ CONTAINER_STOP_RC -ne 0 ]]; then - debug "Failed killing container $CONTAINER_NAME RC $CONTAINER_STOP_RC ." - fi - done -fi -debug "Stopped all remaining containers ..." - # Stop the docker container engine. Otherwise we will have a broken docker storage systemctl stop docker.service || debug "Ignore stopping docker service error $?"