Skip to content

Commit bf79c95

Browse files
authored
[warm/fast reboot] some service docker might have been stopped already (#668)
* [warm/fast reboot] some service docker might have been stopped already Some services are depending on swss and might have been stopped at the time the loop of docker killing was executed. Signed-off-by: Ying Xie <[email protected]> * log and ignore all errors while killing containers * add debug message * put redirect at the right place
1 parent b19b125 commit bf79c95

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scripts/fast-reboot

+10-2
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,14 @@ if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
423423
# then immediately call `systemctl stop teamd` to prevent the service from
424424
# restarting the container automatically.
425425
# Note: teamd must be killed before syncd, because it will send the last packet through CPU port
426+
debug "Stopping teamd ..."
426427
docker exec -i teamd pkill -USR2 teamd || [ $? == 1 ]
427428
while docker exec -i teamd pgrep teamd > /dev/null; do
428429
sleep 0.05
429430
done
430431
docker kill teamd > /dev/null
431432
systemctl stop teamd
433+
debug "Stopped teamd ..."
432434
fi
433435
434436
# Kill swss Docker container
@@ -464,7 +466,7 @@ if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; t
464466
# Send USR1 signal to all teamd instances to stop them
465467
# It will prepare teamd for warm-reboot
466468
# Note: We must send USR1 signal before syncd, because it will send the last packet through CPU port
467-
docker exec -i teamd pkill -USR1 teamd || [ $? == 1 ] > /dev/null
469+
docker exec -i teamd pkill -USR1 teamd > /dev/null || [ $? == 1 ]
468470
debug "Stopped teamd ..."
469471
fi
470472
@@ -476,10 +478,16 @@ debug "Stopped syncd ..."
476478
# We call `docker kill ...` to ensure the container stops as quickly as possible,
477479
# then immediately call `systemctl stop ...` to prevent the service from
478480
# restarting the container automatically.
481+
debug "Stopping all remaining containers ..."
479482
for CONTAINER_NAME in $(docker ps --format '{{.Names}}'); do
480-
docker kill $CONTAINER_NAME > /dev/null
483+
CONTAINER_STOP_RC=0
484+
docker kill $CONTAINER_NAME &> /dev/null || CONTAINER_STOP_RC=$?
481485
systemctl stop $CONTAINER_NAME
486+
if [[ CONTAINER_STOP_RC -ne 0 ]]; then
487+
debug "Failed killing container $CONTAINER_NAME RC $CONTAINER_STOP_RC ."
488+
fi
482489
done
490+
debug "Stopped all remaining containers ..."
483491
484492
# Stop the docker container engine. Otherwise we will have a broken docker storage
485493
systemctl stop docker.service

0 commit comments

Comments
 (0)