From 260526c23cabdfbc2468bb5f0895a587227f40ed Mon Sep 17 00:00:00 2001 From: Prabhat Aravind Date: Wed, 27 Dec 2023 21:38:56 +0000 Subject: [PATCH 1/2] [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 Signed-off-by: Prabhat Aravind --- files/build_templates/docker_image_ctl.j2 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 2093622daac6..b31cd261f585 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -283,6 +283,12 @@ function postStartAction() fi chgrp -f redis $REDIS_SOCK && chmod -f 0760 $REDIS_SOCK {%- elif docker_container_name == "swss" %} + # Wait until swss container state is Running + until [[ ($(docker inspect -f {{"'{{.State.Running}}'"}} swss) == "true") ]]; do + sleep 0.1 + done + echo "swss container is up and running" + docker exec swss$DEV rm -f /ready # remove cruft if [[ "$BOOT_TYPE" == "fast" ]] && [[ -d /host/fast-reboot ]]; then test -e /host/fast-reboot/fdb.json && docker cp /host/fast-reboot/fdb.json swss$DEV:/ @@ -292,6 +298,9 @@ function postStartAction() rm -fr /host/fast-reboot fi docker exec swss$DEV touch /ready # signal swssconfig.sh to go + # Re-confirm that file is indeed created and log an error if not + docker exec swss$DEV test -f /ready && echo "File swss:/ready created" || echo "Error: File swss:/ready doesn't exist" + {%- elif docker_container_name == "pmon" %} DEVPATH="/usr/share/sonic/device" From b8585c5d9ae9baec708bfc65880067de6f893767 Mon Sep 17 00:00:00 2001 From: Prabhat Aravind Date: Tue, 2 Jan 2024 23:03:31 +0000 Subject: [PATCH 2/2] [docker_image_ctl.j2]: Use swss$DEV to accommodate multi ASIC platforms as well Signed-off-by: Prabhat Aravind --- files/build_templates/docker_image_ctl.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index b31cd261f585..95c2e1fa52a8 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -284,7 +284,7 @@ function postStartAction() chgrp -f redis $REDIS_SOCK && chmod -f 0760 $REDIS_SOCK {%- elif docker_container_name == "swss" %} # Wait until swss container state is Running - until [[ ($(docker inspect -f {{"'{{.State.Running}}'"}} swss) == "true") ]]; do + until [[ ($(docker inspect -f {{"'{{.State.Running}}'"}} swss$DEV) == "true") ]]; do sleep 0.1 done echo "swss container is up and running"