Skip to content

Commit d2d825c

Browse files
prabhataravindmssonicbld
authored andcommitted
[docker_image_ctl.j2]: swss docker initialization improvements (sonic-net#17628)
* [docker_image_ctl.j2]: swss docker initialization improvements This commit attempts to address the following: * Make sure swss container is indeed up and running before running any commands on it. In case where swss container is not fully up when swss.sh attempts to create swss:/ready file using "docker exec swss$DEV touch", the command can fail silently and can cause swssconfig to wait forever leading to missing IP decap configuration among other things. Add a wait so that docker commands are run only after swss container status is "Running" * Add a log when swss:/ready file is created or if the file creation fails so that it becomes easier to debug such scenarios in the future * [docker_image_ctl.j2]: Use swss$DEV to accommodate multi ASIC platforms as well Signed-off-by: Prabhat Aravind <paravind@microsoft.com>
1 parent 78c8f11 commit d2d825c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

files/build_templates/docker_image_ctl.j2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ function postStartAction()
283283
fi
284284
chgrp -f redis $REDIS_SOCK && chmod -f 0760 $REDIS_SOCK
285285
{%- elif docker_container_name == "swss" %}
286+
# Wait until swss container state is Running
287+
until [[ ($(docker inspect -f {{"'{{.State.Running}}'"}} swss$DEV) == "true") ]]; do
288+
sleep 0.1
289+
done
290+
echo "swss container is up and running"
291+
286292
docker exec swss$DEV rm -f /ready # remove cruft
287293
if [[ "$BOOT_TYPE" == "fast" ]] && [[ -d /host/fast-reboot ]]; then
288294
test -e /host/fast-reboot/fdb.json && docker cp /host/fast-reboot/fdb.json swss$DEV:/
@@ -292,6 +298,9 @@ function postStartAction()
292298
rm -fr /host/fast-reboot
293299
fi
294300
docker exec swss$DEV touch /ready # signal swssconfig.sh to go
301+
# Re-confirm that file is indeed created and log an error if not
302+
docker exec swss$DEV test -f /ready && echo "File swss:/ready created" || echo "Error: File swss:/ready doesn't exist"
303+
295304
{%- elif docker_container_name == "pmon" %}
296305

297306
DEVPATH="/usr/share/sonic/device"

0 commit comments

Comments
 (0)