Skip to content

Commit 288c2d8

Browse files
Revert "[scripts/fast-reboot] Shutdown remaining containers through systemd (#2133)" (#2161)
This reverts commit 23e9398. - What I did Revert "[scripts/fast-reboot] Shutdown remaining containers through systemd (#2133)" This reverted PR is part of a story that refactors warm/fast shutdown sequence to gracefully stop services instead of killing them without any ordering and dependency requirements which creates several issues and is error prone for the future. This PR must come together with #10510. However, #10510 is blocked due to an issue in swss-common sonic-net/sonic-swss-common#603 And a fix by MSFT is in review sonic-net/sonic-swss-common#606 I am reverting it because its dependency is still blocked and we cannot update submodule pointer. Once the dependency of the reverted PR is resolved, it shall be re-committed.
1 parent bce4694 commit 288c2d8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

scripts/fast-reboot

+20
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,26 @@ 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+
741761
# Stop the docker container engine. Otherwise we will have a broken docker storage
742762
systemctl stop docker.service || debug "Ignore stopping docker service error $?"
743763

0 commit comments

Comments
 (0)