Skip to content

Commit 23e9398

Browse files
[scripts/fast-reboot] Shutdown remaining containers through systemd (sonic-net#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 <[email protected]>
1 parent 576c9ef commit 23e9398

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

scripts/fast-reboot

-20
Original file line numberDiff line numberDiff line change
@@ -738,26 +738,6 @@ for service in ${SERVICES_TO_STOP}; do
738738
fi
739739
done
740740
741-
# Kill other containers to make the reboot faster
742-
# We call `docker kill ...` to ensure the container stops as quickly as possible,
743-
# then immediately call `systemctl stop ...` to prevent the service from
744-
# restarting the container automatically.
745-
debug "Stopping all remaining containers ..."
746-
if test -f /usr/local/bin/ctrmgr_tools.py
747-
then
748-
/usr/local/bin/ctrmgr_tools.py kill-all
749-
else
750-
for CONTAINER_NAME in $(docker ps --format '{{.Names}}'); do
751-
CONTAINER_STOP_RC=0
752-
docker kill $CONTAINER_NAME &> /dev/null || CONTAINER_STOP_RC=$?
753-
systemctl stop $CONTAINER_NAME || debug "Ignore stopping $CONTAINER_NAME error $?"
754-
if [[ CONTAINER_STOP_RC -ne 0 ]]; then
755-
debug "Failed killing container $CONTAINER_NAME RC $CONTAINER_STOP_RC ."
756-
fi
757-
done
758-
fi
759-
debug "Stopped all remaining containers ..."
760-
761741
# Stop the docker container engine. Otherwise we will have a broken docker storage
762742
systemctl stop docker.service || debug "Ignore stopping docker service error $?"
763743

0 commit comments

Comments
 (0)